A presenter clicks through a deck of slides, and scores[i] is how much the audience likes slide i (it can be negative). The talk starts on slide 0 and must end on the last slide. Each click jumps forward between 1 and reach slides.
Write maxSlideScore(scores, reach) that returns the largest total score of the slides shown, counting the first and the last slide.
Input: scores = [2,-1,-3,5,-8,4], reach = 2 Output: 10
Show slides 0, 1, 3, 5: 2 - 1 + 5 + 4.
Input: scores = [8,-4,-3,5,0,2], reach = 3 Output: 15
Show slides 0, 3, and 5: 8 + 5 + 2.
1 <= scores.length <= 1000001 <= reach <= 100000-10000 <= scores[i] <= 10000Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #501 Hop Through Slides for Max Score. 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.