Tap here to switch tabs
Problem
Submissions

Problem: Neighboring Bitwise XOR

med
30 min
Try to solve the Neighboring Bitwise XOR problem.

Statement

A 00 indexed binary array original of length n is transformed into a derived binary array derived of length n by computing the bitwise $ ext{XOR}$ of adjacent elements:

  • For each index i such that 0≤0 \leq i <n−1< n - 1, derived[i] == original[i] ⊕\oplus original[i + 1].

  • For the last index n - 1, derived[n - 1] == original[n - 1] ⊕\oplus original[0].

Given the array derived, return true if there exists a valid binary array original that could have produced derived, or false otherwise.

Constraints:

  • n == derived.length

  • 1≤1 \leq n ≤105\leq 10^5

  • derived[i] is either 00 or 11 for all valid indices i

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Neighboring Bitwise XOR

med
30 min
Try to solve the Neighboring Bitwise XOR problem.

Statement

A 00 indexed binary array original of length n is transformed into a derived binary array derived of length n by computing the bitwise $ ext{XOR}$ of adjacent elements:

  • For each index i such that 0≤0 \leq i <n−1< n - 1, derived[i] == original[i] ⊕\oplus original[i + 1].

  • For the last index n - 1, derived[n - 1] == original[n - 1] ⊕\oplus original[0].

Given the array derived, return true if there exists a valid binary array original that could have produced derived, or false otherwise.

Constraints:

  • n == derived.length

  • 1≤1 \leq n ≤105\leq 10^5

  • derived[i] is either 00 or 11 for all valid indices i