Maximum Subarray XOR with Bounded Range

The runner passes one array of decimal-string tokens. The last token is the bound k; every earlier token is one number of the array nums, written as a decimal string. Both values are non-negative integers below 2^15. Pick a contiguous subarray of nums whose maximum element minus its minimum element is at most k. Its value is the bitwise XOR of all its elements. Return the largest value over all valid subarrays, or 0 when the input is empty, too short to hold at least one number plus k, or contains an invalid token.

  • Input: ["5", "4", "5", "6", "2"]
  • Output: 7
Examples
Input: ["5","4","5","6","2"]
Output: 7
Hints

Maximum Subarray XOR with Bounded Range

The runner passes one array of decimal-string tokens. The last token is the bound `k`; every earlier token is one number of the array `nums`, written as a decimal string. Both values are non-negative integers below 2^15. Pick a contiguous subarray of `nums` whose maximum element minus its minimum element is at most `k`. Its value is the bitwise XOR of all its elements. Return the largest value over all valid subarrays, or 0 when the input is empty, too short to hold at least one number plus `k`, or contains an invalid token.