Skip to content

Commit aabf1d4

Browse files
committed
single_number_II
1 parent 8077c43 commit aabf1d4

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ Golang solution for leetcode. For each problem, there is a simple *_test.go to t
120120
#### [134. gas station](https://github.com/hitzzc/go-leetcode/tree/master/gas_station)
121121
#### [135. candy](https://github.com/hitzzc/go-leetcode/tree/master/candy)
122122
#### [136. single number](https://github.com/hitzzc/go-leetcode/tree/master/single_number)
123+
#### [137. single number II](https://github.com/hitzzc/go-leetcode/tree/master/single_number_II)
123124

124125

125126

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package single_number_II
2+
3+
func singleNumber(nums []int) int {
4+
var one, two, three int
5+
for i := range nums {
6+
two |= one & nums[i]
7+
one ^= nums[i]
8+
three = one & two
9+
one &= ^three
10+
two &= ^three
11+
}
12+
return one
13+
}

0 commit comments

Comments
 (0)