1829. Maximum XOR for Each Query
https://leetcode.com/problems/maximum-xor-for-each-query
Description
You are given a sorted array nums
of n
non-negative integers and an integer maximumBit
. You want to perform the following query n
times:
Find a non-negative integer
k < 2maximumBit
such thatnums[0] XOR nums[1] XOR ... XOR nums[nums.length-1] XOR k
is maximized.k
is the answer to theith
query.Remove the last element from the current array
nums
.
Return an array answer
, where answer[i]
is the answer to the ith
query.
Example 1:
Example 2:
Example 3:
Constraints:
nums.length == n
1 <= n <= 105
1 <= maximumBit <= 20
0 <= nums[i] < 2maximumBit
nums
is sorted in ascending order.
ac
Previous1828. Queries on Number of Points Inside a CircleNext1830. Minimum Number of Operations to Make String Sorted
Last updated