public class Solution { public int[] SingleNumber(int[] nums) { var dic = new Dictionary<int, int>(); foreach (var num in nums) { if (!dic.ContainsKey(num)) { dic.Add(num, 1); } else { dic[num]++; } } var list = dic.OrderBy(x => x.Value).ToList(); var ary = new int[2]; ary[0] = list[0].Key; ary[1] = list[1].Key; return ary; } }
https://leetcode.com/problems/single-number-iii/#/description