You are given a non-negative integer array nums and an integer k.
You must select a subarray of nums such that the difference between its maximum and minimum elements is at most k. The value of this subarray is the bitwise XOR of all elements in the subarray.
Return an integer denoting the maximum possible value of the selected subarray.
Example 1:
Input: nums = [5,4,5,6], k = 2
Output: 7
Explanation:
[5, 4, 5, 6].6 - 4 = 2 <= k.4 XOR 5 XOR 6 = 7.Example 2:
Input: nums = [5,4,5,6], k = 1
Output: 6
Explanation:
[5, 4, 5, 6].6 - 6 = 0 <= k.
Constraints:
1 <= nums.length <= 4 * 1040 <= nums[i] < 2150 <= k < 215Solutions for this problem are being prepared.
Try solving it yourselfPractice Maximum Subarray XOR with Bounded Range with our built-in code editor and test cases.
Practice on FleetCodePractice this problem
Open in Editor