Skip to content

Files

Latest commit

e10e79b · Sep 4, 2022

History

History

349-IntersectionofTwoArrays

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Sep 4, 2022
Sep 4, 2022

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.