prefixXOR
with the same length as arr
plus one, and set the first element to 0.arr
and setting prefixXOR[i+1]
to prefixXOR[i] XOR arr[i]
.result
to store the XOR results for each query.[left, right]
in queries
, compute the XOR for the range by XORing prefixXOR[left]
and prefixXOR[right + 1]
, and append the result to result
.result
list.