mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
31 lines
1.0 KiB
HTML
31 lines
1.0 KiB
HTML
|
<p>给你一个字符串 <code>s</code> 和一个字符串数组 <code>dictionary</code> ,找出并返回 <code>dictionary</code> 中最长的字符串,该字符串可以通过删除 <code>s</code> 中的某些字符得到。</p>
|
|||
|
|
|||
|
<p>如果答案不止一个,返回长度最长且字母序最小的字符串。如果答案不存在,则返回空字符串。</p>
|
|||
|
|
|||
|
<p> </p>
|
|||
|
|
|||
|
<p><strong>示例 1:</strong></p>
|
|||
|
|
|||
|
<pre>
|
|||
|
<strong>输入:</strong>s = "abpcplea", dictionary = ["ale","apple","monkey","plea"]
|
|||
|
<strong>输出:</strong>"apple"
|
|||
|
</pre>
|
|||
|
|
|||
|
<p><strong>示例 2:</strong></p>
|
|||
|
|
|||
|
<pre>
|
|||
|
<strong>输入:</strong>s = "abpcplea", dictionary = ["a","b","c"]
|
|||
|
<strong>输出:</strong>"a"
|
|||
|
</pre>
|
|||
|
|
|||
|
<p> </p>
|
|||
|
|
|||
|
<p><strong>提示:</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> 和 <code>dictionary[i]</code> 仅由小写英文字母组成</li>
|
|||
|
</ul>
|