A dashboard lays out panels in a row, and heights[i] is the height of panel i. A sidebar is on the far right. A panel has a clear view of the sidebar if every panel to its right is strictly shorter.
Write clearView(heights) that returns the indexes of the panels with a clear view, in increasing order. The last panel always has one.
Input: heights = [4,2,3,1] Output: [0,2,3]
Panel 1 (height 2) is blocked by panel 2 (height 3).
Input: heights = [4,3,2,1] Output: [0,1,2,3]
Heights only go down, so every panel can see.
1 <= heights.length <= 10^51 <= heights[i] <= 10^9Run 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 #264 Panels With a Clear View. 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.