Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
457 B
2
Indexable
Never
def find(left,right):
    rangesit2 = right - left + 1
    res = 0
    temp = 0
    for _ in range(2):
        rangesit2 = rangesit2 // 2
        tmp_left = left // 2
        if right == left: 
            res = (1<<temp) | res
        else:
            res = (0<< temp ) | res
        if rangesit2 == tmp_left:
            return res
        else:
            temp = tmp_left// rangesit2
            right >>= temp
            left >>= temp

    return res
Leave a Comment