My python solution


  • 0
    K
    class Solution(object):
    def rangeBitwiseAnd(self, m, n):
        """
        :type m: int
        :type n: int
        :rtype: int
        """
        ret = 0
        delta = 1
        while m+delta <= n:
            ret ^= delta
            delta *= 2
        return ret

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.