Solved LeetCode program · 84 of 1,000
#0084 · Largest Rectangle in Histogram
Original English source
The heights is a list of 2, 1, 5, 6, 2, and 3. The last is the last position of heights. The best is 0.
For every left from 0 to last.
The minimum is item left of heights.
For every right from left to last.
If item right of heights is less than minimum, set minimum to item right of heights. The area is minimum times (right minus left plus 1). If area is more than best, set best to area.
Show best.
Expected stdout
10