XOR of 1..N — Solution & Editorial
The prefix XOR is periodic with period 4: it equals N, 1, N+1, 0 for N ≡ 0, 1, 2, 3 (mod 4).
Complexity: O(1)
The prefix XOR is periodic with period 4: it equals N, 1, N+1, 0 for N ≡ 0, 1, 2, 3 (mod 4).
Complexity: O(1)