Class Solution
java.lang.Object
g0701_0800.s0720_longest_word_in_dictionary.Solution
720 - Longest Word in Dictionary.<p>Medium</p>
<p>Given an array of strings <code>words</code> representing an English Dictionary, return <em>the longest word in</em> <code>words</code> <em>that can be built one character at a time by other words in</em> <code>words</code>.</p>
<p>If there is more than one possible answer, return the longest word with the smallest lexicographical order. If there is no answer, return the empty string.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> words = [“w”,“wo”,“wor”,“worl”,“world”]</p>
<p><strong>Output:</strong> “world”</p>
<p><strong>Explanation:</strong> The word “world” can be built one character at a time by “w”, “wo”, “wor”, and “worl”.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> words = [“a”,“banana”,“app”,“appl”,“ap”,“apply”,“apple”]</p>
<p><strong>Output:</strong> “apple”</p>
<p><strong>Explanation:</strong> Both “apply” and “apple” can be built from other words in the dictionary. However, “apple” is lexicographically smaller than “apply”.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= words.length <= 1000</code></li>
<li><code>1 <= words[i].length <= 30</code></li>
<li><code>words[i]</code> consists of lowercase English letters.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
longestWord
-