mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
63 lines
2.3 KiB
HTML
63 lines
2.3 KiB
HTML
<p>给你两个字符串数组 <code>words1</code> 和 <code>words2</code>。</p>
|
||
|
||
<p>现在,如果 <code>b</code> 中的每个字母都出现在 <code>a</code> 中,<strong>包括重复出现的字母</strong>,那么称字符串 <code>b</code> 是字符串 <code>a</code> 的 <strong>子集</strong> 。</p>
|
||
|
||
<ul>
|
||
<li>例如,<code>"wrr"</code> 是 <code>"warrior"</code> 的子集,但不是 <code>"world"</code> 的子集。</li>
|
||
</ul>
|
||
|
||
<p>如果对 <code>words2</code> 中的每一个单词 <code>b</code>,<code>b</code> 都是 <code>a</code> 的子集,那么我们称 <code>words1</code> 中的单词 <code>a</code> 是<em> </em><strong>通用单词</strong><em> </em>。</p>
|
||
|
||
<p>以数组形式返回 <code>words1</code> 中所有的通用单词。你可以按 <strong>任意顺序</strong> 返回答案。</p>
|
||
|
||
<p> </p>
|
||
|
||
<ol>
|
||
</ol>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["e","o"]
|
||
<strong>输出:</strong>["facebook","google","leetcode"]
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["l","e"]
|
||
<strong>输出:</strong>["apple","google","leetcode"]
|
||
</pre>
|
||
|
||
<p><strong>示例 3:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["e","oo"]
|
||
<strong>输出:</strong>["facebook","google"]
|
||
</pre>
|
||
|
||
<p><strong>示例 4:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["lo","eo"]
|
||
<strong>输出:</strong>["google","leetcode"]
|
||
</pre>
|
||
|
||
<p><strong>示例 5:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["ec","oc","ceo"]
|
||
<strong>输出:</strong>["facebook","leetcode"]
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>1 <= words1.length, words2.length <= 10<sup>4</sup></code></li>
|
||
<li><code>1 <= words1[i].length, words2[i].length <= 10</code></li>
|
||
<li><code>words1[i]</code> 和 <code>words2[i]</code> 仅由小写英文字母组成</li>
|
||
<li><code>words1</code> 中的所有字符串 <strong>互不相同</strong></li>
|
||
</ul>
|