Tap here to switch tabs
Problem
Submissions

Problem: Maximum XOR for Each Query

med
30 min
Try to solve the Maximum XOR for Each Query problem.

Statement

You are given a sorted integer array nums containing nn non negative integers, and an integer maximumBit.

You must execute nn queries as follows:

  1. Determine a non negative integer k such that 0≤k<2ext‘maximumBit‘0 \leq k < 2^{ ext{`maximumBit`}} and the bitwise XOR sum of all elements in the current array nums along with k is maximized.

  2. Remove the last element from the current array nums.

Return an array ans of size nn, where ans[i] represents the answer to the iextthi^{ ext{th}} query.

Constraints:

  • nums.length ==n== n

  • 1≤n≤1051 \leq n \leq 10^5

  • 1≤1 \leq maximumBit ≤20\leq 20

  • 0≤0 \leq nums[i] <2ext‘maximumBit‘< 2^{ ext{`maximumBit`}}

  • nums is sorted in ascending order.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum XOR for Each Query

med
30 min
Try to solve the Maximum XOR for Each Query problem.

Statement

You are given a sorted integer array nums containing nn non negative integers, and an integer maximumBit.

You must execute nn queries as follows:

  1. Determine a non negative integer k such that 0≤k<2ext‘maximumBit‘0 \leq k < 2^{ ext{`maximumBit`}} and the bitwise XOR sum of all elements in the current array nums along with k is maximized.

  2. Remove the last element from the current array nums.

Return an array ans of size nn, where ans[i] represents the answer to the iextthi^{ ext{th}} query.

Constraints:

  • nums.length ==n== n

  • 1≤n≤1051 \leq n \leq 10^5

  • 1≤1 \leq maximumBit ≤20\leq 20

  • 0≤0 \leq nums[i] <2ext‘maximumBit‘< 2^{ ext{`maximumBit`}}

  • nums is sorted in ascending order.