A code review leaderboard shows reviewers in a row with their quality scores, scores. Each reviewer gets a whole number of reward points with two rules: everyone gets at least 1 point, and a reviewer with a strictly higher score than a neighbor next to them in the row must get more points than that neighbor.
Write fewestPoints(scores) that returns the smallest total number of points that follows both rules.
Input: scores = [1,0,2] Output: 5
Give 2, 1, 2 points.
Input: scores = [1,2,2] Output: 4
Give 1, 2, 1: the last reviewer ties with their neighbor, so 1 point is enough.
0 <= scores.length <= 1000000 <= scores[i] <= 4 * 10^4Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #596 Fewest Reward Points for Reviewers. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.