n bits (zeros and ones) are written around a circle. For each bit we took the XOR with its clockwise neighbor: diffs[i] is the XOR of bit i and bit i + 1, and the last bit is paired with the first. When n = 1, the bit is paired with itself.
The original bits are lost; only the array diffs remains. Return True if at least one ring of bits produces exactly this diffs, and False otherwise.diffs=[1, 0, 1] → True
The ring [0, 1, 1] works: 0 ⊕ 1 = 1, 1 ⊕ 1 = 0, 1 ⊕ 0 = 1.
diffs=[1, 1, 1] → False
All three neighboring pairs would have to differ, but on a ring of three bits that is impossible: coming back to the first bit, its value would have flipped an odd number of times.
diffs=[0] → True
diffs is 0 or 1diffs=[1, 0, 1]
True
Run checks the first 3 tests in your browser. Submit checks all 94 tests on the server, hidden ones included.