链接:LeetCode201
过程:想了想,看题解,求前缀用位移和Brian Kernighan算法
思路:略
代码:
class Solution {
public int rangeBitwiseAnd(int m, int n) {
int cnt=0;
while(m<n){
n=n&(n-1);
}
return n;
}
}
链接:LeetCode201
过程:想了想,看题解,求前缀用位移和Brian Kernighan算法
思路:略
代码:
class Solution {
public int rangeBitwiseAnd(int m, int n) {
int cnt=0;
while(m<n){
n=n&(n-1);
}
return n;
}
}