Skip to content

Commit 40c99b6

Browse files
committed
[LeetCode Sync] Runtime - 0 ms (100.00%), Memory - 17.9 MB (43.17%)
1 parent a4ff867 commit 40c99b6

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<p>Given two integer arrays <code>nums1</code> and <code>nums2</code>, return <em>an array of their <span data-keyword="array-intersection">intersection</span></em>. Each element in the result must be <strong>unique</strong> and you may return the result in <strong>any order</strong>.</p>
2+
3+
<p>&nbsp;</p>
4+
<p><strong class="example">Example 1:</strong></p>
5+
6+
<pre>
7+
<strong>Input:</strong> nums1 = [1,2,2,1], nums2 = [2,2]
8+
<strong>Output:</strong> [2]
9+
</pre>
10+
11+
<p><strong class="example">Example 2:</strong></p>
12+
13+
<pre>
14+
<strong>Input:</strong> nums1 = [4,9,5], nums2 = [9,4,9,8,4]
15+
<strong>Output:</strong> [9,4]
16+
<strong>Explanation:</strong> [4,9] is also accepted.
17+
</pre>
18+
19+
<p>&nbsp;</p>
20+
<p><strong>Constraints:</strong></p>
21+
22+
<ul>
23+
<li><code>1 &lt;= nums1.length, nums2.length &lt;= 1000</code></li>
24+
<li><code>0 &lt;= nums1[i], nums2[i] &lt;= 1000</code></li>
25+
</ul>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Solution:
2+
def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]:
3+
return list(set(nums1) & set(nums2))

0 commit comments

Comments
 (0)