数组---10. Intersection of Two Arrays

class Solution:
    def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]:
        return list(set(nums1) & set(nums2))

set取交集的方法:&

你可能感兴趣的:(数组---10. Intersection of Two Arrays)