Error in code for xor

Hi , What is wrong in my code , I have considered all the test cases

All you have to do is for every pair from x to y , compute (x^y) and update your answer for maximum.
You code complexity will be O(x*y).

You can refer this for better understanding.

#include using namespace std; int main () { int x,y,xr=0,p=1; cin>>x>>y; if(x==y) { cout<<xr<<endl; } else { int a=0,b=0,r=0,s=0; while(y>0) { r = y & 1; s = x & 1; if(r==s && y>1) { if(r==0) { s=1; } if(r==1) { r=0; } } a = a + rp; b = b + sp; x = x>>1; y = y>>1; p = p*2; } xr = a ^ b; cout<<xr<<endl; } return 0; }

Please don’t send raw code. Paste your code on cb.lk/ide and then after saving , send the link.

Why are you doing all this? You might have left some cases.
Have a look at the constraints for the problem.
We can solve the problem in O(n^2) by making all pairs and getting maximum answer.
If you are trying to do something raw, then you need to decode your problems yourself.

You can solve it in this way as well, which is very efficient to do.
Please have a look

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.