mirror of
https://github.com/lWolvesl/leetcode.git
synced 2026-02-27 03:38:08 +08:00
7 lines
90 B
Go
7 lines
90 B
Go
package A
|
|
|
|
func hasAlternatingBits(n int) bool {
|
|
n = n ^ (n >> 1)
|
|
return n&(n+1) == 0
|
|
}
|