【力扣】136. 只出现一次的数字
时间复杂度:\(O(n)\)
空间复杂度:\(O(1)\)
class Solution {
public int singleNumber(int[] nums) {
int result = 0;
for (int num : nums) {
result ^= num;
}
return result;
}
}
时间复杂度:\(O(n)\)
空间复杂度:\(O(1)\)
class Solution {
public int singleNumber(int[] nums) {
int result = 0;
for (int num : nums) {
result ^= num;
}
return result;
}
}