[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

浙公网安备 33010602011771号