mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
27 lines
1.1 KiB
HTML
27 lines
1.1 KiB
HTML
<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> </p>
|
|
<p><strong class="example">Example 1:</strong></p>
|
|
|
|
<pre>
|
|
<strong>Input:</strong> s = "abpcplea", dictionary = ["ale","apple","monkey","plea"]
|
|
<strong>Output:</strong> "apple"
|
|
</pre>
|
|
|
|
<p><strong class="example">Example 2:</strong></p>
|
|
|
|
<pre>
|
|
<strong>Input:</strong> s = "abpcplea", dictionary = ["a","b","c"]
|
|
<strong>Output:</strong> "a"
|
|
</pre>
|
|
|
|
<p> </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>
|