Skip to content

Commit

Permalink
add sol
Browse files Browse the repository at this point in the history
  • Loading branch information
ductnn committed Feb 21, 2024
1 parent caaa5b0 commit be27d2a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions leetcode/201.BitwiseANDofNumbersRange/bitwiseANDofNumbersRange.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// https://leetcode.com/problems/bitwise-and-of-numbers-range

package main

import (
"fmt"
)

func rangeBitwiseAnd(left int, right int) int {
for left < right {
right &= (right - 1)
}
return right
}

func main() {
left := 1
right := 2147483647

fmt.Println(rangeBitwiseAnd(left, right))
}

0 comments on commit be27d2a

Please sign in to comment.