Vị trí zero cuối cùng

Cách 1
 avatar
tocdovodoi
plain_text
a year ago
252 B
6
Indexable
s = input()
left, right = 0, len(s) - 1
index = -1

while left <= right:
    mid = (left + right) // 2
    if s[mid] == '0':
        index = mid
        left = mid + 1
    else:
        right = mid - 1

if index != -1:
    print(index + 1)
Editor is loading...
Leave a Comment