add new solutions
This commit is contained in:
parent
f249852923
commit
f297e11859
10 changed files with 373 additions and 0 deletions
12
solutions/10/q1009/solution.go
Normal file
12
solutions/10/q1009/solution.go
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// Package q1009 implements a solution for https://leetcode.com/problems/complement-of-base-10-integer/
|
||||
package q1009
|
||||
|
||||
func bitwiseComplement(n int) int {
|
||||
i := 1
|
||||
for i <= n {
|
||||
i <<= 1
|
||||
}
|
||||
return n ^ max(i-1, 1)
|
||||
}
|
||||
|
||||
var _ = bitwiseComplement
|
||||
Loading…
Add table
Add a link
Reference in a new issue