LeetCode #442: Find All Duplicates in an Array
β’ 31 words β’ 1 min
LeetCode #442: Find All Duplicates in an Array:
Easy with Counter:
class Solution:
def findDuplicates(self, nums: List[int]) -> List[int]:
return [num for (num, count) in Counter(nums).most_common() if count == 2]
Related Posts
LeetCode #2215: Find the Difference of Two Arrays:
python class Solution: def findDifference(self, nums1: List[int], nums2: List[int]) -> β¦
Jan 06, 2026
LeetCode #1991: Find the Middle Index in Array:
python from itertools import accumulate class Solution: def findMiddleIndex(self, nums: List[int]) β¦
Jan 06, 2026
Previously, previously, previously, previously, previously.
Thiago Perrotta