a guest Nov 16th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand