1-line Python code

  • 0
    class Solution(object):
    def intersection(self, nums1, nums2):
        :type nums1: List[int]
        :type nums2: List[int]
        :rtype: List[int]
        return [x for x in set(nums1) if x in set(nums2)]

  • 0

    Why My solution return set(nums1) & set(nums2)
    has something wrong?
    Exception: Type <type 'set'>: Not implemented

  • 0

    Q`s request is :rtype: List[int] , solution is return list(set(nums1) & set(nums2))

  • 0

    Just want to point out that we only need one of set(nums1) and set(nums2)

Log in to reply

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