medium

Range XOR Queries with Updates

An integer array receives a stream of two kinds of queries: set position i to value v, or report the bitwise XOR of all elements from l to r inclusive. Answer every query efficiently.

Constraints
  • 1 ≤ n, q ≤ 2 · 10^5
  • 0 ≤ a[i], v < 2^30
  • 0 ≤ l ≤ r < n
Examples
in: a = [1,3,4,8]; xor(1,3), update(2,6), xor(0,2)
out: 15, 4

Code it yourself

Solve in
Test execution is not yet available for this exercise.Practice journal →Draft saved in this browser.
Hints:
Which approach applies?

Choose an approach to check your pattern recognition, or reveal the discussion when you need help.