Trie interview problem

Hey, why are we doing i+1 in rbest when finding result

result = max(result, lbest[i]+rbest[i+1];

hello @Rakshitgarg99
because we dont want to include same element in both lbeast and rbest .because in given problem we have to found disjoint subarray.

thats why lbest[i] which give max xor subarray in index range [0…i]

and rbest[i+1] which give max xor subarray in index range [i+1…n-1]

(notice [0…i] and [i+1…n-1] are disjoint )

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.