Max xor pair problem

The code shown here gives correct output for
array shown in the explanation video but gives wrong answer for array ike 1 2 3 4(answer should be 7 but we get answer=6) if we use the code given in the video?


Link to the code

this should be (n >> i ) & 1
line no 17 and 48 needs to be updated
image

image