Skip to content

Commit 8a33730

Browse files
committed
bitwise_AND_of_numbers_range
1 parent a5a647e commit 8a33730

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ Golang solution for leetcode. For each problem, there is a simple *_test.go to t
159159
#### [198. House Robber](https://github.com/hitzzc/go-leetcode/tree/master/house_robber)
160160
#### [199. Binary Tree Right Side View](https://github.com/hitzzc/go-leetcode/tree/master/binary_tree_right_side_view)
161161
#### [200. Number of Islands](https://github.com/hitzzc/go-leetcode/tree/master/number_of_islands)
162+
#### [201. Bitwise AND of Numbers Range](https://github.com/hitzzc/go-leetcode/tree/master/bitwise_AND_of_numbers_range)
162163

163164

164165

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package bitwise_AND_of_numbers_range
2+
3+
func rangeBitwiseAnd(m int, n int) int {
4+
var cnt uint = 0
5+
for m != n {
6+
cnt++
7+
m >>= 1
8+
n >>= 1
9+
}
10+
return m << cnt
11+
}

0 commit comments

Comments
 (0)