3206. Find Common Elements Between Two Arrays
My accepted Python solution to LeetCode problem 3206, Find Common Elements Between Two Arrays, running in 0ms.
- Difficulty: Easy
- Python
- Runtime 0ms
- Memory 17.4MB
- 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 0ms, memory 17.4MB, accepted 2026-01-02.
class Solution:
def findIntersectionValues(self, nums1: List[int], nums2: List[int]) -> List[int]:
set1 = set(nums1)
set2 = set(nums2)
answer1 = sum(1 for x in nums1 if x in set2)
answer2 = sum(1 for x in nums2 if x in set1)
return [answer1, answer2]