Back to course home
0% completed
Vote For New Content
XOR Queries of a Subarray (medium)
Problem Statement
You are given an array arr containing integers greater than 0. Additionally, you are given the array of queries where queries[i] = [left<sub>i</sub>, right<sub>i</sub>].
For each query, compute the XOR of the elements in arr from index left<sub>i</sub> to right<sub>i</sub> (inclusive)
Return an array answer where answer[i] represents the result of the i<sup>th</sup> query.
Examples
Example 1:
- Input: arr =
[2, 4, 7, 3], queries =[[0, 1], [1, 3], [0, 2]] - Expected Output:
[6, 0, 1] - Explanation:
.....
.....
.....
Like the course? Get enrolled and start learning!