Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND
of all numbers in this range, inclusive.
For example, given the range [5, 7], you should return 4.
一个个的相与肯定是超时的,n到m的变化本质是其中每个bit上1,0的变化,这样就
可以通过n&n-1每次变化一个bit位直到最接近m为止。最多32次循环就得到结果。
public int rangeBitwiseAnd(int m, int n) {
while(n>m)
n=n&n-1;
return m&n;
}