s*******e 发帖数: 182 | 1 Write a function that will return a list of integers that occur only once in
a given array of integers.
For example, given an array: [1,2,3,4,4,3], this function will return [1,2] | l******s 发帖数: 3045 | 2 private IList singles(int[] nums){
ISet result = new HashSet();
ISet multi = new HashSet();
for(int i = 0; i < nums.Length; i++)
if(result.Contains(nums[i])){
result.Remove(nums[i]);
multi.Add(nums[i]);
}
else if (!multi.Contains(nums[i]))
result.Add(nums[i]);
return result.ToList();
} | a****e 发帖数: 9589 | 3 [k for k, v in dict(collections.Counter(l)).items() if v == 1]
in
【在 s*******e 的大作中提到】 : Write a function that will return a list of integers that occur only once in : a given array of integers. : For example, given an array: [1,2,3,4,4,3], this function will return [1,2]
|
|