Skip to content

Practice Maximum XOR Score Subarray Queries

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#3277
LeetCode Problem

Maximum XOR Score Subarray Queries

Problem Statement

Define an array’s XOR score by repeatedly replacing every adjacent pair with its XOR simultaneously, reducing the length by one, until one value remains. Given nums and inclusive queries [l, r], return the maximum such score over all nonempty contiguous subarrays contained in nums[l..r], one result per query.

Source: Maximum XOR Score Subarray Queries on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [2,8,4,32,16,1], queries = [[0,2],[1,4],[0,5]]
Output
[12,60,60]

# Example 2

Input
nums = [0,7,3,2,8,5,1], queries = [[0,3],[1,5],[2,4],[2,6],[5,6]]
Output
[7,14,11,14,5]

Constraints

1 <= n == nums.length <= 2000
0 <= nums[i] <= 2^31 - 1
1 <= q == queries.length <= 10^5
queries[i].length == 2
queries[i] = [li, ri]
0 <= li <= ri <= n - 1

Related LeetCode Problems

Practice more problems similar to Maximum XOR Score Subarray Queries.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.