2025-01-09 20:29:41 +08:00
|
|
|
|
<p>给定两个数组 <code>nums1</code> 和 <code>nums2</code> ,返回 <em>它们的 <span data-keyword="array-intersection">交集</span></em> 。输出结果中的每个元素一定是 <strong>唯一</strong> 的。我们可以 <strong>不考虑输出结果的顺序</strong> 。</p>
|
2022-03-27 20:56:26 +08:00
|
|
|
|
|
|
|
|
|
<p> </p>
|
|
|
|
|
|
|
|
|
|
<p><strong>示例 1:</strong></p>
|
|
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
|
<strong>输入:</strong>nums1 = [1,2,2,1], nums2 = [2,2]
|
|
|
|
|
<strong>输出:</strong>[2]
|
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
|
|
<p><strong>示例 2:</strong></p>
|
|
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
|
<strong>输入:</strong>nums1 = [4,9,5], nums2 = [9,4,9,8,4]
|
|
|
|
|
<strong>输出:</strong>[9,4]
|
|
|
|
|
<strong>解释:</strong>[4,9] 也是可通过的
|
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
|
|
<p> </p>
|
|
|
|
|
|
|
|
|
|
<p><strong>提示:</strong></p>
|
|
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
|
<li><code>1 <= nums1.length, nums2.length <= 1000</code></li>
|
|
|
|
|
<li><code>0 <= nums1[i], nums2[i] <= 1000</code></li>
|
|
|
|
|
</ul>
|