Class Solution
java.lang.Object
g0501_0600.s0524_longest_word_in_dictionary_through_deleting.Solution
524 - Longest Word in Dictionary through Deleting.<p>Medium</p>
<p>Given a string <code>s</code> and a string array <code>dictionary</code>, return <em>the longest string in the dictionary that can be formed by deleting some of the given string characters</em>. If there is more than one possible result, return the longest word with the smallest lexicographical order. If there is no possible result, return the empty string.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> s = “abpcplea”, dictionary = [“ale”,“apple”,“monkey”,“plea”]</p>
<p><strong>Output:</strong> “apple”</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> s = “abpcplea”, dictionary = [“a”,“b”,“c”]</p>
<p><strong>Output:</strong> “a”</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= s.length <= 1000</code></li>
<li><code>1 <= dictionary.length <= 1000</code></li>
<li><code>1 <= dictionary[i].length <= 1000</code></li>
<li><code>s</code> and <code>dictionary[i]</code> consist of lowercase English letters.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
findLongestWord
-