Clear python solution with only set()


  • 0
    L
    def intersect(self, nums1, nums2):
        M=[]
        if [set(nums1) & set(nums2)]:
            for i in list(set(nums1) & set(nums2)):
                N=min(nums1.count(i), nums2.count(i))
                for n in range(N):
                    M.append(i)
            return M
    

Log in to reply
 

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