cur
to n & 1
to store the current bit.n
by one bit.n
is greater than zero:
a. If cur
is equal to n & 1
, return false
because two adjacent bits are the same.
b. Update cur
to n & 1
(the new current bit).
c. Right-shift n
by one bit.false
, return true
.