A dashboard layout has vertical dividers placed one unit apart. heights[i] is the height of divider i. You can stretch a panel between any two dividers i < j: its width is j - i and its height is the shorter of the two dividers.
Write largestPanel(heights) that returns the largest panel area, (j - i) * Math.min(heights[i], heights[j]), over all pairs. Return 0 if there are fewer than two dividers.
Input: heights = [2,7,4,1,6,3,5] Output: 25
Dividers 1 and 6 have heights 7 and 5, so the area is 5 * 5 = 25.
Input: heights = [3,3] Output: 3
Width 1, height 3.
0 <= heights.length <= 1000000 <= heights[i] <= 10^4Run 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 #103 Largest Area Between Two Dividers. 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.