Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
325 B
5
Indexable
Never
def distribute_candy(children_ratings):
    total_candy = 0
    previous_child_rating = 0
    previous_child_candy = 0
    for i in range(len(children_ratings)):
        if previous_child_rating < i:
            previous_child_candy += 1
            total_candy += previous_child_candy
        previous_child_candy =