As reported: Rubrik SDE-1 online assessment for 2026 graduates (2026), section 1, question 1.
An array A of size N is good if the XOR of every subarray is non-zero.
In one operation you choose an index i and replace A[i] with any value X ≥ 0. Find the minimum number of operations needed to make A good.
Example 1
A = [1,3,2,5] -> 1
1 ^ 3 ^ 2 = 0. Changing 2 to, say, 64 fixes it, and no other subarray XORs to 0.
Example 2
A = [0] -> 1
A single 0 is itself a subarray with XOR 0.
Constraints: 1 ≤ N ≤ 10^5; 0 ≤ A[i] < 2^30.
Code runner format: one line holding A as a JSON array (one test case per run). Implement minOperations(a); the harness prints the minimum.
Clarifications
- In the original input there are
T ≤ 10^5test cases (the sum ofNis at most3·10^5), each given asNand then theNintegers; here each run is one test case.