A music app gives each song in a queue an energy level, stored in order in energy. To build a playlist that never calms down, you may drop songs but not reorder them, and each kept song must have energy greater than or equal to the song before it.
Write longestSteadyPlaylist(energy) that returns the most songs such a playlist can keep.
Input: energy = [3,1,2,2,5,4] Output: 4
1, 2, 2, 5 (or 1, 2, 2, 4). Equal energy is allowed.
Input: energy = [9,8,7] Output: 1
Every song is calmer than the one before it, so only one can stay.
1 <= energy.length <= 10000 <= energy[i] <= 100Run 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 #529 Longest Steady Energy Playlist. 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.