Loading...
You are given an array of integers nums and a list of queries. Each element in queries contains [i, j], meaning the query asks for nums[i] ^ nums[i + 1] ^ ... ^ nums[j], the bitwise XOR of every element in nums from index i to index j, both ends inclusive.
Return an array answer where answer[k] is the result of the k-th query in queries.
Input: nums = [1,3,4,8], queries = [[0,1],[1,2],[0,3]]
Output: [2,7,14]
Explanation:
- Query [0,1] covers indices 0 and 1: 1 ^ 3 = 2.
- Query [1,2] covers indices 1 and 2: 3 ^ 4 = 7.
- Query [0,3] covers every element: 1 ^ 3 ^ 4 ^ 8 = 14.
Input: nums = [5], queries = [[0,0]]
Output: [5]
Explanation: The only query covers the single element, so the result is 5 itself.
nums.length ≤105nums[i] ≤109queries.length ≤105queries[k].length ==2nums.lengthClick "Run" to test with sample cases or "Submit" to run all tests.