leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

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 };