giving run time error,what should i do?
Trie interview question
Hello @Vibhuti0206
I think your approach to solve this problem is wrong.
We need to find two Non overlapping ranges with maximum XOR sum of the two ranges.
HINT to solve the problem
- int result = 0;
- Traverse the array, let say we are at index “i”, we consider index “i” to be the end of the first range
- Get the maximum sub array xor for elements upto index “i”, sub array ending at index “i” (Let it be x1)
// This part is simply the maximum XOR subarray question - Implement some function say “GetRightXORMax” which return the maximum sub array xor from index “i + 1” to end of the array (Let it be x2) // This function should be implemented in O(1) time complexity.
- if(x1 + x2 > result) {
- result = x1 + x2
- }
- print result;
Here is the code
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.