Add solution 1009

This commit is contained in:
halfrost
2021-12-29 21:21:21 +08:00
parent 32a5c605c6
commit 5b5bbb2ebe
3 changed files with 128 additions and 0 deletions

View File

@ -0,0 +1,9 @@
package leetcode
func bitwiseComplement(n int) int {
mask := 1
for mask < n {
mask = (mask << 1) + 1
}
return mask ^ n
}