1、题目描述
2、代码详解
异或运算
public class SingleNumber_136 {
public static void main(String[] args){
int[] nums = {4, 1, 2, 1, 2};
System.out.println(singleNumber(nums));
}
public static int singleNumber(int[] nums){
int res = 0;
for(int num: nums)
res ^= num;
return res;
}
}