Skip to content

Commit

Permalink
Update 136.single-number.md
Browse files Browse the repository at this point in the history
  • Loading branch information
azl397985856 authored Aug 16, 2020
1 parent 88bc8ff commit 97fbc0a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion problems/136.single-number.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ Your algorithm should have a linear runtime complexity. Could you implement it w

## 前置知识

- 位运算
- [位运算](https://github.com/azl397985856/leetcode/blob/master/thinkings/bit.md)

## 公司

- airbnb
- palantir
## 思路

根据题目描述,由于加上了时间复杂度必须是 O(n),并且空间复杂度为 O(1)的条件,因此不能用排序方法,也不能使用 map 数据结构。
Expand Down Expand Up @@ -151,6 +155,9 @@ class Solution:
single_number ^= num
return single_number
```
**复杂度分析**
- 时间复杂度:$O(N)$
- 空间复杂度:$O(1)$

## 延伸

Expand All @@ -177,3 +184,11 @@ class Solution:
`两个独特的的数字`在那一位一定是不同的,因此两个独特元素一定会被分成不同组。

Done!


更多题解可以访问我的LeetCode题解仓库:https://github.com/azl397985856/leetcode 。 目前已经35K star啦。

关注公众号力扣加加,努力用清晰直白的语言还原解题思路,并且有大量图解,手把手教你识别套路,高效刷题。


![](https://tva1.sinaimg.cn/large/007S8ZIlly1gfcuzagjalj30p00dwabs.jpg)

0 comments on commit 97fbc0a

Please sign in to comment.