Given two integers left and right that represent the range [left, right], return the bitwise AND of all numbers in this range, inclusive.

&nbsp;
Example 1:

Input: left = 5, right = 7
Output: 4


Example 2:

Input: left = 0, right = 0
Output: 0


Example 3:

Input: left = 1, right = 2147483647
Output: 0


&nbsp;
Constraints:


	0 &lt;= left &lt;= right &lt;= 231 - 1


class Solution:
    def rangeBitwiseAnd(self, left: int, right: int) -> int:
        if not left: return 0
        i = 0
        cur = left
        while cur + (cur & -cur) <= right:
            cur += cur & -cur
            left &= cur
        return left
class Solution {
public int rangeBitwiseAnd(int left, int right) {
    int count=0;
    while(left!=right){
        left>>=1;
        right>>=1;
        count++;
    }
    return right<<=count;
}
class Solution {
public:
    int rangeBitwiseAnd(int left, int right) {
        int t=0;
        while(left!=right){
            left= left>>1;
            right= right>>1;
            t++;
        }
        int ans= left;
        while(t--){
            ans= ans<<1;
        }
        return ans;
    }
};
var rangeBitwiseAnd = function(left, right) {
    const a = left.toString(2);
    const b = right.toString(2);

    if (a.length !== b.length) {
        return 0;
    }

    let match = 0;

    for (let i = 0; i < a.length; i++) {
        if (a[i] !== b[i]) {
            break;
        }

        match++;
    }

    return parseInt(b.substring(0, match).padEnd(b.length, '0'), 2);
};
Bitwise AND of Numbers Range