add new solutions
This commit is contained in:
parent
0f5f9e331c
commit
a7ff717b7a
7 changed files with 221 additions and 0 deletions
15
solutions/6/q693/solution.go
Normal file
15
solutions/6/q693/solution.go
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
package q693
|
||||
|
||||
func hasAlternatingBits(n int) bool {
|
||||
last := -1
|
||||
for n > 0 {
|
||||
if last == n%2 {
|
||||
return false
|
||||
}
|
||||
last = n % 2
|
||||
n >>= 1
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
var _ = hasAlternatingBits
|
||||
Loading…
Add table
Add a link
Reference in a new issue