Please check what is wrong in my code.
2 test cases pass but 1 fail and 1 gives TLE.
Link to my code : https://ide.codingblocks.com/s/207720
Please help
Please check what is wrong in my code.
2 test cases pass but 1 fail and 1 gives TLE.
Link to my code : https://ide.codingblocks.com/s/207720
Please help
The reason is time complexity, O(N^2) in your case, you logic is right, but you reduce the time by maintaining two seperate arrays left and right.
here left[i] will represent the max xor till i and right[i] will denote the max xor from i to till n.
Just maintain two different array for both the directions.
Anyways your code and logic is great, just optimize it.
I hope it helps
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.