add new solutions
This commit is contained in:
parent
475d438db4
commit
1433bf4850
17 changed files with 394 additions and 0 deletions
13
solutions/1/q191/solution.go
Normal file
13
solutions/1/q191/solution.go
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
package q191
|
||||
|
||||
func hammingWeight(n int) int {
|
||||
num := 0
|
||||
for ; n > 0; n >>= 1 {
|
||||
if n|1 == n {
|
||||
num++
|
||||
}
|
||||
}
|
||||
return num
|
||||
}
|
||||
|
||||
var _ = hammingWeight
|
||||
Loading…
Add table
Add a link
Reference in a new issue