Q1 Optimal

mail@pastecode.io avatar
unknown
plain_text
2 years ago
219 B
2
Indexable
Never
def get_moments(arr):
    cnt = 0
    max_turned_all = 0
    for idx, a in enumerate(arr):
        max_turned_all = max(max_turned_all, a)
        if max_turned_all == idx + 1:
            cnt += 1
    return cnt