1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/统计出现过一次的公共字符串 [count-common-words-with-one-occurrence].html

43 lines
1.5 KiB
HTML
Raw Normal View History

2022-03-27 20:38:29 +08:00
<p>给你两个字符串数组&nbsp;<code>words1</code>&nbsp;&nbsp;<code>words2</code>&nbsp;,请你返回在两个字符串数组中 <strong>都恰好出现一次</strong>&nbsp;的字符串的数目。</p>
<p>&nbsp;</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>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= words1.length, words2.length &lt;= 1000</code></li>
<li><code>1 &lt;= words1[i].length, words2[j].length &lt;= 30</code></li>
<li><code>words1[i]</code>&nbsp;<code>words2[j]</code>&nbsp;都只包含小写英文字母。</li>
</ul>