A homepage carousel loops: after the last slide it shows the first one again, so the first and last slides are neighbors. values[i] is the value of featuring slide i. Two neighboring slides may not both be featured.
Write featureSlides(values) that returns the largest total value of featured slides. Featuring none is allowed.
Input: values = [4,5,4] Output: 5
Slides 0 and 2 are neighbors in the loop, so the best is slide 1 alone.
Input: values = [2,3,4,2] Output: 6
Slides 0 and 2: 2 + 4.
1 <= values.length <= 10000 <= values[i] <= 1000Run 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 #496 Featured Slides on a Looping Carousel. 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.