python solution (one line actually)


  • 1
    H
        import collections
        counter1 = collections.Counter(nums1)
        counter2 = collections.Counter(nums2)
        return list((counter1 & counter2).elements())

Log in to reply
 

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