Find All Duplicates in an Array LeetCode solution in Python
1class Solution:2def findDuplicates(self, nums: List[int]) -> List[int]:3res = []4hm = {}5# adding entries in hashmap to check frequency6for i, v in enumerate(nums):7if v not in hm:8hm[v] = 19else:10hm[v] += 111# checking frequency of item and adding output to an array12for key, value in hm.items():13if value > 1:14res.append(key)15return res