Bitwise AND of Numbers Range

Solution Code
class Solution:
    def rangeBitwiseAnd(self, left: int, right: int) -> int:
        shift = 0
        while left < right:
            left >>= 1
            right >>= 1
            shift += 1
        return left << shift
Video GuideLeetcode Daily

Time Complexity

O(1)

Space Complexity

O(1)