Leetcode 136. Single Number
Given an array of integers, every element appears twice except for one. Find that single one.
This question is so intended to examine about the bit manipulation, because when the number do the XOR with itself, the result would be 0;
public class Solution {
public int singleNumber(int[] nums) {
int num = 0;
int leng = nums.length;
for(int i = 0; i < leng; i++){
num = nums[i] ^ num;
}
return num;
}
}