Tap here to switch tabs
Problem
Submissions

Problem: XOR Queries of a Subarray

Try to solve the XOR Queries of a Subarray problem.

Statement

You are given an array of positive integers arr and an array queries where each query is represented as queries[i] = [left_i, right_i].

For each query i, compute the bitwise XOR of all elements from index left_i to right_i inclusive (that is, arr[left_i] ^ arr[left_i + 1] ^ ... ^ arr[right_i]).

Return an array containing the results of all queries in the given order.

Constraints:

  • 1≤1 \leq arr.length, queries.length ≤3×104\leq 3 \times 10^4

  • 1≤1 \leq arr[i] ≤109\leq 10^9

  • queries[i].length =2= 2

  • 0≤lefti≤righti<0 \leq left_i \leq right_i < arr.length

⋮
Tap here to switch tabs
Problem
Submissions

Problem: XOR Queries of a Subarray

Try to solve the XOR Queries of a Subarray problem.

Statement

You are given an array of positive integers arr and an array queries where each query is represented as queries[i] = [left_i, right_i].

For each query i, compute the bitwise XOR of all elements from index left_i to right_i inclusive (that is, arr[left_i] ^ arr[left_i + 1] ^ ... ^ arr[right_i]).

Return an array containing the results of all queries in the given order.

Constraints:

  • 1≤1 \leq arr.length, queries.length ≤3×104\leq 3 \times 10^4

  • 1≤1 \leq arr[i] ≤109\leq 10^9

  • queries[i].length =2= 2

  • 0≤lefti≤righti<0 \leq left_i \leq right_i < arr.length