题目描述:
知识点:位运算
低位混乱,& 出来的结果不会一致,所以只需要看最小数和最大数对应的高位情况。
public static int rangeBitwiseAnd3(int m, int n) { if(m == 0){ return 0; } int temp = 1; while(m != n){ m >>= 1; n >>= 1; temp <<= 1; } return m * temp; }