Loading

[Python手撕]多个数组求交集

class Solution:
    def intersection(self, nums: List[List[int]]) -> List[int]:
        length = len(nums)
        map = {}
        for num in nums:
            for n in num:
                map[n] = map.get(n,0)+1
        res = []
        for key,value in map.items():
            if value == length:
                res.append(key)
        return res
posted @ 2024-09-26 10:51  Duancf  阅读(19)  评论(0)    收藏  举报