Skip to content

Commit 9ec9ac1

Browse files
committed
350
1 parent ef8ccf9 commit 9ec9ac1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Jul-2-24.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution:
2+
def intersect(self, nums1: List[int], nums2: List[int]) -> List[int]:
3+
res = []
4+
a = Counter(nums1)
5+
b = Counter(nums2)
6+
if len(a.keys())>len(b.keys()):
7+
for i in b.keys():
8+
for j in range(min(a[i],b[i])):
9+
res.append(i)
10+
else:
11+
for i in a.keys():
12+
for j in range(min(a[i],b[i])):
13+
res.append(i)
14+
return res

0 commit comments

Comments
 (0)