Find the maximum subarray XOR in a given array - GeeksforGeeks
Find the maximum subarray XOR in a given array
Given an array of integers. find the maximum XOR subarray value in given array. Expected time complexity O(n).
Examples:
Input: arr[] = {1, 2, 3, 4} Output: 7 The subarray {3, 4} has maximum XOR value Input: arr[] = {8, 1, 2, 12, 7, 6} Output: 15 The subarray {1, 2, 12} has maximum XOR value Input: arr[] = {4, 6} Output: 6 The subarray {6} has maximum XOR value
We strongly recommend you to minimize your browser and try this yourself first.
A Simple Solution is to use two loops to find XOR of all subarrays and return the maximum.
Read full article from Find the maximum subarray XOR in a given array - GeeksforGeeks
No comments:
Post a Comment