A 0-indexed array
derived
with lengthn
is derived by computing the bitwise XOR (⊕) of adjacent values in a binary arrayoriginal
of lengthn
.Specifically, for each index
i
in the range[0, n - 1]
:
- If
i = n - 1
, thenderived[i] = original[i] ⊕ original[0]
.- Otherwise,
derived[i] = original[i] ⊕ original[i + 1]
.Given an array
derived
, your task is to determine whether there exists a valid binary arrayoriginal
that could have formedderived
.Return *true if such an array exists or false otherwise.*
- A binary array is an array containing only 0’s and 1’s
1 | class Solution { |