Problem can be found in here!
Solution: Hash Table
def intersection(nums1: List[int], nums2: List[int]) -> List[int]:
nums1_set, nums2_set = set(nums1), set(nums2)
return list(nums1_set & nums2_set)
Explanation: We can use set operation to solve this problem. Just find the intersection of two arrays.
Time Complexity: , Space Complexity:
, where n and m is the length of nums1 and nums2, respectively.