using System; using System.Collections.Generic; class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param nums int整型一维数组 * @return int整型一维数组 */ public List<int> FindNumsAppearOnce (List<int> nums) { Dictionary<int,bool> res = new Dictionary<int,bool>(); foreach(int num in nums){ if(res.ContainsKey(num)){ res.Remove(num); } else{ res.Add(num, true); } } List<int> result = new List<int>(); foreach(int num in res.Keys){ result.Add(num); } if(result[0] > result[1]){ result[0] = result[0] ^ result[1]; result[1] = result[0] ^ result[1]; result[0] = result[0] ^ result[1]; } return result; } }