I used two for loops to solve this problem can it be solved in other way?
Can this problem be solved in less than O(n^2) time?
@Deepanshu_garg hey Deepanshu there is another approach
#include < iostream >
using namespace std;
int main(){
int a,b;
cin>>a>>b;
int xr = a ^ b;
int msbpos=0;
while(xr){
msbpos + +;
xr = xr > >1;
}
int maxxr=0;
int x=1;
while(msbpos - - ){
maxxr + = x;
x = x < < 1;
}
cout<<maxxr;
}