How can we do this

Example 2 2 4 5 5
ans = 2^2 =0
then ans = 4^5= 1
ans = 5^5=0;
so at the end answer should be zero i guess but program is also giving output as 4 but i am not able to understand it please help.

we are taking xor of ans with no

NOTE: xor with zero will not effect the no a^0=a

intilally ans =0
we do ans=ans^no; every time

ans=0^2=2
ans=2^2=0
ans=0^4=4;
ans=4^5;
ans=4^5^5=4
hence ans is 4

if you have more doubts regarding this feel free to ask
i hope this helps
if yes hit a like :heart:: and don’t forgot to mark doubt as resolved :grinning:

1 Like

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.