Answer multiple range XOR queries on an array efficiently.
You are given an integer array and several queries. Each query asks for the XOR of all elements in a subarray from index to index inclusive.
For every query, return the XOR value for that range. Since there may be many queries, the solution should be faster than recomputing the XOR from scratch each time.
arr of length n.l and r.arr[l..r].For this record, treat the problem as returning one answer per query in the same order.
i-th value is the XOR of arr[l_i..r_i].If the problem is presented in a function-based format, return the list of answers.
1 <= n, q are typically up to large values, so an efficient preprocessing approach is expected.Example 1
Input
arr = [1, 3, 4, 8] queries = [[0, 1], [1, 2], [0, 3], [3, 3]]
Output
[2, 7, 14, 8]
Explanation
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.