mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
43 lines
1.5 KiB
HTML
43 lines
1.5 KiB
HTML
|
<p>给你两个字符串数组 <code>words1</code> 和 <code>words2</code> ,请你返回在两个字符串数组中 <strong>都恰好出现一次</strong> 的字符串的数目。</p>
|
|||
|
|
|||
|
<p> </p>
|
|||
|
|
|||
|
<p><strong>示例 1:</strong></p>
|
|||
|
|
|||
|
<pre>
|
|||
|
<b>输入:</b>words1 = ["leetcode","is","amazing","as","is"], words2 = ["amazing","leetcode","is"]
|
|||
|
<b>输出:</b>2
|
|||
|
<strong>解释:</strong>
|
|||
|
- "leetcode" 在两个数组中都恰好出现一次,计入答案。
|
|||
|
- "amazing" 在两个数组中都恰好出现一次,计入答案。
|
|||
|
- "is" 在两个数组中都出现过,但在 words1 中出现了 2 次,不计入答案。
|
|||
|
- "as" 在 words1 中出现了一次,但是在 words2 中没有出现过,不计入答案。
|
|||
|
所以,有 2 个字符串在两个数组中都恰好出现了一次。
|
|||
|
</pre>
|
|||
|
|
|||
|
<p><strong>示例 2:</strong></p>
|
|||
|
|
|||
|
<pre>
|
|||
|
<b>输入:</b>words1 = ["b","bb","bbb"], words2 = ["a","aa","aaa"]
|
|||
|
<b>输出:</b>0
|
|||
|
<b>解释:</b>没有字符串在两个数组中都恰好出现一次。
|
|||
|
</pre>
|
|||
|
|
|||
|
<p><strong>示例 3:</strong></p>
|
|||
|
|
|||
|
<pre>
|
|||
|
<b>输入:</b>words1 = ["a","ab"], words2 = ["a","a","a","ab"]
|
|||
|
<b>输出:</b>1
|
|||
|
<b>解释:</b>唯一在两个数组中都出现一次的字符串是 "ab" 。
|
|||
|
</pre>
|
|||
|
|
|||
|
<p> </p>
|
|||
|
|
|||
|
<p><strong>提示:</strong></p>
|
|||
|
|
|||
|
<ul>
|
|||
|
<li><code>1 <= words1.length, words2.length <= 1000</code></li>
|
|||
|
<li><code>1 <= words1[i].length, words2[j].length <= 30</code></li>
|
|||
|
<li><code>words1[i]</code> 和 <code>words2[j]</code> 都只包含小写英文字母。</li>
|
|||
|
</ul>
|