1-line python solution


  • 0
    L
    from compiler.ast import flatten
    class Solution(object):
        def intersect(self, nums1, nums2):
            """
            :type nums1: List[int]
            :type nums2: List[int]
            :rtype: List[int]
            """
            return flatten([[x]*min(nums1.count(x),nums2.count(x)) for x in set(nums1)])

Log in to reply
 

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