Problem statement

https://binarysearch.com/problems/XOR-Range-Queries/

Solution

Equal to 1310. XOR Queries of a Subarray.

Complexity

It is O(n + q) for time and space.

Code

class Solution:
    def solve(self, arr, Q):
        acc = [0] + list(accumulate(arr, xor))
        return [acc[y + 1]^acc[x] for x, y in Q]