int rangeBitwiseAnd(int m, int n) {
int c=0;
while(m!=n){
m>>=1;
n>>=1;
++c;
}
return n<<c;
}
the result of a range bitwise is the common 'left header' of m and n.
Hello redace85, I can understand your code, lets say, m = 5 and n = 7 as given in the input... after 2 right shifts, m and n becomes equal and the c's value is 2. and again, you're performing n << c which returns 4 as expected but what is happening during right shifts, but can you please explain how range bitwise is happening here ? could not get the logic !!