One lined Python solution


  • 0
    C
    def intersection(nums1, nums2):
            return [n for n in set(nums2) if n in set(nums1)]
    

    or:

    def intersection(nums1, nums2):
                return list(set(nums1) & set(nums2))

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.