import java.util.Arrays;
public class Solution {
public int[] singleNumber(int[] nums) {
int[] result = new int[2];
int res = 0;
for(int d : nums){
res ^= d;
}
int temp = res;
int bitOp = res;
int count = 0;
while (bitOp != 0 && (bitOp&1) != 1){
bitOp >>= 1;
count++;
}
for(int d : nums){
if(((d>>count)&1) == 1){
temp ^= d;
}
}
result[0] = temp;
result[1] = temp ^ res;
return result;
}
public static void main(String[] args){
System.out.println(Arrays.toString(new Solution().singleNumber(new int[]{43772400,1674008457,1779561093,744132272,1674008457,448610617,1779561093,124075538,-1034600064,49040018,612881857,390719949,-359290212,-812493625,124732,-1361696369,49040018,-145417756,-812493625,2078552599,1568689850,865876872,865876872,-1471385435,1816352571,1793963758,2078552599,-1034600064,1475115274,-119634980,124732,661111294,-1813882010,1568689850,448610617,1347212898,-1293494866,612881857,661111294,-1361696369,1816352571,-1813882010,-359290212,1475115274,1793963758,1347212898,43772400,-1471385435,124075538,-1293494866,-119634980,390719949})));
}
}
求数组中不重复的两个数
最新推荐文章于 2021-10-28 11:29:58 发布