public class Solution { public int[] SingleNumber(int[] nums) { var hash = new Dictionary(); for(var i = 0;i < nums.Length; i++) { if(hash.ContainsKey(nums[i])){ hash[nums[i]] ++; } else{ hash.Add(nums[i], 1); } } var ret = new List (); foreach(var k in hash.Keys){ if(hash[k] == 1){ ret.Add(k); } if(ret.Count == 2){ break; } } return ret.ToArray(); } }