1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/通过删除字母匹配到字典里最长单词 [longest-word-in-dictionary-through-deleting].html
2022-03-29 12:43:11 +08:00

31 lines
1.0 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个字符串 <code>s</code> 和一个字符串数组 <code>dictionary</code> ,找出并返回&nbsp;<code>dictionary</code> 中最长的字符串,该字符串可以通过删除 <code>s</code> 中的某些字符得到。</p>
<p>如果答案不止一个,返回长度最长且字母序最小的字符串。如果答案不存在,则返回空字符串。</p>
<p>&nbsp;</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>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= s.length &lt;= 1000</code></li>
<li><code>1 &lt;= dictionary.length &lt;= 1000</code></li>
<li><code>1 &lt;= dictionary[i].length &lt;= 1000</code></li>
<li><code>s</code><code>dictionary[i]</code> 仅由小写英文字母组成</li>
</ul>