2331. Intersection of Multiple Arrays
My accepted Python solution to LeetCode problem 2331, Intersection of Multiple Arrays, running in 3ms.
- Difficulty: Easy
- Python
- Runtime 3ms
- Memory 17.7MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 3ms, memory 17.7MB, accepted 2026-01-01.
class Solution:
def intersection(self, nums: List[List[int]]) -> List[int]:
count = {}
for arr in nums:
for num in arr:
count[num] = count.get(num, 0) + 1
n = len(nums)
return sorted([num for num, c in count.items() if c == n])