0201.cpp (242B)
1 class Solution { 2 public: 3 int rangeBitwiseAnd(int left, int right) { 4 int cnt = 0; 5 while (left != right) { 6 cnt++; 7 left >>= 1; 8 right >>= 1; 9 } 10 return left << cnt; 11 } 12 };