Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]:
- ans = []
- nums1 = set(nums1)
- nums2 = set(nums2)
- if (len(nums1) < len(nums2)):
- for x in nums1:
- if x in nums2:
- if x not in ans:
- ans.append(x)
- else:
- for x in nums2:
- if x in nums1:
- if x not in ans:
- ans.append(x)
- return ans
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement