2248. Intersection of Multiple Arrays

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 2248

class Solution:
    def intersection(self, nums: List[List[int]]) -> List[int]:
        cnt = Counter()
        res = []
        for arr in nums:
            for x in arr:
                cnt[x] += 1
                if cnt[x] == len(nums):
                    res.append(x)
        res.sort()
        return res