public class Solution { Dictionarydic = new Dictionary (); public IList FindDuplicates(int[] nums) { var list = new List (); foreach (var n in nums) { if (!dic.ContainsKey(n)) { dic.Add(n, 1); } else { list.Add(n); } } return list; }}
本文共 578 字,大约阅读时间需要 1 分钟。
public class Solution { Dictionarydic = new Dictionary (); public IList FindDuplicates(int[] nums) { var list = new List (); foreach (var n in nums) { if (!dic.ContainsKey(n)) { dic.Add(n, 1); } else { list.Add(n); } } return list; }}
转载于:https://www.cnblogs.com/asenyang/p/6797188.html