public class Solution { Dictionary<int, int> dic = new Dictionary<int, int>(); public IList<int> FindDuplicates(int[] nums) { var list = new List<int>(); foreach (var n in nums) { if (!dic.ContainsKey(n)) { dic.Add(n, 1); } else { list.Add(n); } } return list; } }
https://leetcode.com/problems/find-all-duplicates-in-an-array/#/description