Advertisement
Guest User

Untitled

a guest
Nov 16th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. class Solution:
  2. def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]:
  3. ans = []
  4. nums1 = set(nums1)
  5. nums2 = set(nums2)
  6. if (len(nums1) < len(nums2)):
  7. for x in nums1:
  8. if x in nums2:
  9. if x not in ans:
  10. ans.append(x)
  11. else:
  12. for x in nums2:
  13. if x in nums1:
  14. if x not in ans:
  15. ans.append(x)
  16. return ans
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement