Skip to content

Commit 55e0231

Browse files
committed
Time: 53 ms (34.01%), Space: 16.6 MB (95.4%) - LeetHub
1 parent aafb978 commit 55e0231

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution:
2+
def intersect(self, nums1: List[int], nums2: List[int]) -> List[int]:
3+
nums1.sort()
4+
nums2.sort()
5+
i,j=0,0
6+
intersection=[]
7+
while i<len(nums1) and j<len(nums2):
8+
if nums1[i]<nums2[j]:
9+
i+=1
10+
elif nums1[i]>nums2[j]:
11+
j+=1
12+
else:
13+
intersection.append(nums1[i])
14+
i+=1
15+
j+=1
16+
return intersection

0 commit comments

Comments
 (0)