Bitwise AND of Numbers Range

Problem Id: 201 Difficulty: Medium


Intuition

Solution


class Solution:
    def rangeBitwiseAnd(self, m, n):
        """
        :type m: int
        :type n: int
        :rtype: int
        """
        while m < n:
            n &= n-1
        return n