Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

Intersection of Two Arrays

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: O(n+m), Space Complexity: O(n+m), where n and m is the length of nums1 and nums2, respectively.