Clean Concise Python Solution Beats 90%


  • 0
    J
    from collections import Counter as ct
    class Solution(object):
        def intersect(self, nums1, nums2):
            c3 = ct(nums1)&ct(nums2)
            ret = []
            for ch in c3:
                ret.extend([ch]*c3[ch])
            return ret
    

Log in to reply
 

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