Description
You are given an array arr of positive integers and queries. For each query queries[i] = [Li, Ri], compute the XOR of elements from Li to Ri. Return an array answer where answer[i] is the answer to the i-th query.
Examples
Input:
arr = [1,3,4,8], queries = [[0,1],[1,2],[0,3],[3,3]]Output:
[2,7,14,8]Explanation:
XOR results for each query.
Input:
arr = [2,5,6,3,9], queries = [[0,4],[2,3],[1,1],[0,2]]Output:
[7,5,5,3]Explanation:
For query [0,4]: XOR of entire array = 2^5^6^3^9 = 7. For query [2,3]: 6^3 = 5. For query [1,1]: single element 5. For query [0,2]: 2^5^6 = 3.
Input:
arr = [10,7,12,4,1], queries = [[0,0],[1,3],[2,4],[0,2]]Output:
[10,11,9,1]Explanation:
For query [0,0]: single element 10. For query [1,3]: 7^12^4 = 11. For query [2,4]: 12^4^1 = 9. For query [0,2]: 10^7^12 = 1.
Constraints
- •
1 ≤ arr.length, queries.length ≤ 3 * 10^4