java.lang.Object
g0501_0600.s0524_longest_word_in_dictionary_through_deleting.Solution

public class Solution extends Object
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 = &ldquo;abpcplea&rdquo;, dictionary = [&ldquo;ale&rdquo;,&ldquo;apple&rdquo;,&ldquo;monkey&rdquo;,&ldquo;plea&rdquo;]</p> <p><strong>Output:</strong> &ldquo;apple&rdquo;</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> s = &ldquo;abpcplea&rdquo;, dictionary = [&ldquo;a&rdquo;,&ldquo;b&rdquo;,&ldquo;c&rdquo;]</p> <p><strong>Output:</strong> &ldquo;a&rdquo;</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 Details

    • Solution

      public Solution()
  • Method Details