mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-25 12:14:26 +08:00
Add solution 1009
This commit is contained in:
@ -0,0 +1,9 @@
|
||||
package leetcode
|
||||
|
||||
func bitwiseComplement(n int) int {
|
||||
mask := 1
|
||||
for mask < n {
|
||||
mask = (mask << 1) + 1
|
||||
}
|
||||
return mask ^ n
|
||||
}
|
Reference in New Issue
Block a user