aboutsummaryrefslogtreecommitdiff
path: root/intersection_2_array.py
blob: 9c884bd09ed4d7bfc5adfbb8fe7ed76bf04b0de8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 349. Intersection of Two Arrays

"""
given two integer arrays 'nums1' and 'nums2' return an array of their
intersection. each element in the result must be unique and you may return
the result in any order.
"""


class Solution(object):
    def intersection(self, nums1, nums2):
        """
        :type nums1: List[int]
        :type nums2: List[int]
        :rtype: List[int]
        """
        return list(set(nums1).intersection(set(nums2)))


if __name__ == "__main__":
    obj = Solution()
    print(obj.intersection(nums1=[1, 2, 2, 1], nums2=[2, 2]))
    print(obj.intersection(nums1=[4, 9, 5], nums2=[9, 4, 9, 8, 4]))