1387. Maximum XOR Subarray (Prefix XOR + Trie)

HardBit ManipulationXOR TriePrefix XORSubarray

Given an array of non-negative integers, return the maximum XOR obtainable from any non-empty contiguous subarray.

Input: A JSON object {"arr": [<non-negative integers>]}.

Output: Return the maximum XOR over all subarrays.

Examples

Example 1
Input: {"arr":[1,2,3,4]}
Output: 7
Explanation: The subarray [3,4] gives 3 XOR 4 = 7, the maximum.
Example 2
Input: {"arr":[8,1,2,12,7,6]}
Output: 15
Explanation: The best subarray XOR is 15.

Constraints

Asked by

AmazonGoogleMicrosoftMetaAdobe
Solve this problem in the editor →