> For the complete documentation index, see [llms.txt](https://shuati.gitbook.io/crack-lintcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://shuati.gitbook.io/crack-lintcode/linkedin/single-number.md).

# Single Number

A simple solution, using 2 properties of XOR: **A ⊕ A = 0** and **B ⊕ 0 = B**\
In other words, **A ⊕ A ⊕ B = B**

```java
class Solution {
    public int singleNumber(int[] nums) {
        
        
        for(int i = 0; i< nums.length-1; i++){
            nums[i+1] ^= nums[i];
        }
        
        return nums[nums.length-1];
    }
}
```
