scores[i]. The teacher hands out stickers following two rules:
- every pupil gets at least one sticker;
- a pupil whose score is higher than a neighbour's in the line must get more stickers than that neighbour.
Return the smallest total number of stickers that satisfies both rules.scores=[3, 5, 5, 1] → 6
Hand out 1, 2, 2, 1: the two middle pupils outscore their lower neighbours, and since they tie with each other there is no rule between them. 6 in total.
scores=[9, 7, 4] → 6
Scores go down, so stickers must go down too: 3, 2, 1, which is 6.
scores=[2] → 1
scores=[3, 5, 5, 1]
6
Run checks the first 3 tests in your browser. Submit checks all 115 tests on the server, hidden ones included.