201. Bitwise AND of Numbers Range
problem description
Input: [5,7]
Output: 4Input: [0,1]
Output: 0algorithm thought
code
class Solution {
public:
int rangeBitwiseAnd(int m, int n) {
return n>m?(rangeBitwiseAnd((m>>1),(n>>1))<<1):m;
}
};algorithm analysis
Last updated