数组中只出现一次的数
数组中只出现一次的数字
http://www.nowcoder.com/questionTerminal/e02fdb54d7524710a7d664d082bb7811
import java.util.HashSet; import java.util.Iterator; public class Solution { public void FindNumsAppearOnce(int [] array,int num1[] , int num2[]) { HashSet<Integer> set = new HashSet<>(); for(int i = 0;i<array.length;i++){ if(!set.contains(array[i]))set.add(array[i]); else set.remove((Object)array[i]); } Iterator<Integer> it = set.iterator(); if(it.hasNext())num1[0] = it.next(); if(it.hasNext())num2[0] = it.next(); } }