Vị trí zero cuối cùng

Cách 1
 avatar
tocdovodoi
plain_text
2 months ago
252 B
3
Indexable
Never
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)
Leave a Comment