A social feed shows posts in a fixed order, and scores[i] is the expected engagement of post i if it gets a spotlight badge. Two spotlighted posts may never sit next to each other in the feed, because they would look like one big block.
Write spotlightPosts(scores) that returns the largest total engagement you can get by choosing which posts to spotlight. Choosing no posts is allowed.
Input: scores = [3,8,10,2,4] Output: 17
Spotlight posts 0, 2, and 4: 3 + 10 + 4.
Input: scores = [6,2,1,6] Output: 12
Posts 0 and 3 are not neighbors: 6 + 6.
0 <= scores.length <= 10000 <= scores[i] <= 1000Run 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 #494 Spotlight Posts Without Neighbors. 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.