Problem 136: Single Number
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
public class Solution {
public int singleNumber(int[] nums) {
if (nums == null || nums.length == 0) {
return -1;
}
int result = nums[0];
for (int i = 1; i < nums.length; i++) {
result ^= nums[i];
}
return result;
}
}