Tap here to switch tabs
Problem
Submissions

Problem: Maximum XOR Score Subarray Queries

med
30 min
Try to solve the Maximum XOR Score Subarray Queries problem.

Statement

You are given an integer array nums of length nn and a 22D integer array queries, where queries[i] =[li,ri]= [l_i, r_i].

The XOR score of an array is obtained by repeatedly replacing the array with a new array formed by taking the bitwise XOR of adjacent elements, continuing this process until only 11 element remains.

For each query, determine the maximum XOR score among all subarrays of nums[l_i..r_i].

Return an array ans where ans[i] is the maximum XOR score for the iextthi^{ ext{th}} query.

Constraints:

  • 1≤n==1 \leq n == nums.length ≤2000\leq 2000

  • 0≤0 \leq nums[i] ≤231−1\leq 2^{31} - 1

  • 1≤q==1 \leq q == queries.length ≤105\leq 10^5

  • queries[i].length ==2== 2

  • queries[i] =[li,ri]= [l_i, r_i]

  • 0≤li≤ri≤n−10 \leq l_i \leq r_i \leq n - 1

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum XOR Score Subarray Queries

med
30 min
Try to solve the Maximum XOR Score Subarray Queries problem.

Statement

You are given an integer array nums of length nn and a 22D integer array queries, where queries[i] =[li,ri]= [l_i, r_i].

The XOR score of an array is obtained by repeatedly replacing the array with a new array formed by taking the bitwise XOR of adjacent elements, continuing this process until only 11 element remains.

For each query, determine the maximum XOR score among all subarrays of nums[l_i..r_i].

Return an array ans where ans[i] is the maximum XOR score for the iextthi^{ ext{th}} query.

Constraints:

  • 1≤n==1 \leq n == nums.length ≤2000\leq 2000

  • 0≤0 \leq nums[i] ≤231−1\leq 2^{31} - 1

  • 1≤q==1 \leq q == queries.length ≤105\leq 10^5

  • queries[i].length ==2== 2

  • queries[i] =[li,ri]= [l_i, r_i]

  • 0≤li≤ri≤n−10 \leq l_i \leq r_i \leq n - 1