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

# Problem 136: Single Number

> <https://leetcode.com/problems/single-number/>

## 思路

* 这道题用了异或关系的特性

  ![](/files/-Lpv9xo7VPWuHrq32ji9)
* 异或关系性质

![](/files/-Lpv9xo9FhgqYlmIksvi)

* 这道题我们就用最后两个的性质，最后剩下的就是那个落单的数字

```java
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;
    }
}
```
