The idea is to find out when a particular bit of the result is 1. When any number having the i'th bit as 0 comes between m and n, the i'th bit of the resulting AND operation will be 0, no matter anything else.

Here are the binary forms for reference:

00 = 0000

01 = 0001

02 = 0010

03 = 0011

04 = 0100

05 = 0101

06 = 0110

07 = 0111

08 = 1000

09 = 1001

10 = 1010

11 = 1011

12 = 1100

13 = 1101

14 = 1110

15 = 1111

.

.

As you can see, the 0th bit from the right will be 1 only when both m and n are in the interval [1] or [3] or [5] or [7] and so on.

Similarly, the 1st bit from right will be 1 only when both m and n are in the interval [2..3] or [6..7] or [10..11] or [14..15] and so on.

2nd bit from right will be 1 only when both m and n are in the interval [4..7] or [12..15] or [20..23] or [28..31] and so on.

In other words, i'th bit from right is 1 if (m / 2^i) % 2 == 1 and (n / 2^i) % 2 == 1 and (m / 2^i) == (n / 2^i).

```
public class Solution {
public int rangeBitwiseAnd(int m, int n) {
int result = 0;
for (int i = 0; i < 31; i++) {
int x = m / (1 << i);
int y = n / (1 << i);
if (x%2 != 0 && y%2 != 0 && x == y) {
result |= (1 << i);
}
}
return result;
}
}
```