class Solution {

public:

int rangeBitwiseAnd(int m, int n)

{

```
vector<int> bitv;
int highb = floor(log2(m)) +1;
int highb1 = floor(log2(n)) +1;
if (highb1 > highb) { return 0; }
else{
bitv.push_back(1);
m = m - pow(2,highb-1);
n = n - pow(2,highb-1);
for (int i = highb; i!= 1; i--)
{
int highbm = floor(log2(m)) + 1;
int highbn = floor(log2(n)) + 1;
if (highbn == i-1) {
n = n - pow(2,highbn-1);
if (highbm == highbn) { m = m - pow(2,highbm-1);bitv.push_back(1);}
else {bitv.push_back(0);}
} else { bitv.push_back(0);}
}
int leng = bitv.size();
transform(bitv.begin(),bitv.end(),bitv.begin(),[&leng](int x) {leng--;return x*pow(2,leng);});
return accumulate(bitv.begin(),bitv.end(),0);
}
```

}

};