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)/单词子集 [word-subsets].html
2022-03-29 12:43:11 +08:00

63 lines
2.3 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>words1</code>&nbsp;&nbsp;<code>words2</code></p>
<p>现在,如果&nbsp;<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> 中的每一个单词&nbsp;<code>b</code><code>b</code> 都是 <code>a</code> 的子集,那么我们称&nbsp;<code>words1</code> 中的单词 <code>a</code><em> </em><strong>通用单词</strong><em> </em></p>
<p>以数组形式返回&nbsp;<code>words1</code> 中所有的通用单词。你可以按 <strong>任意顺序</strong> 返回答案。</p>
<p>&nbsp;</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>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= words1.length, words2.length &lt;= 10<sup>4</sup></code></li>
<li><code>1 &lt;= words1[i].length, words2[i].length &lt;= 10</code></li>
<li><code>words1[i]</code><code>words2[i]</code> 仅由小写英文字母组成</li>
<li><code>words1</code> 中的所有字符串 <strong>互不相同</strong></li>
</ul>