Largest Rectangle in Histogram (LC #84) finds the max rectangular area. Use a monotonic increasing stack of indices. For each bar, while the stack top is taller, pop it. The popped bar's rectangle extends from the new stack top plus to current index minus . Compute area and update max. At the end, process remaining stack elements with right boundary at the array length. This runs in time and space. The idea is that each bar's rectangle is bounded by the first shorter bars on each side.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
$ curl repovive.com/roadmaps/meta-interview-prep/stacks-queues/largest-rectangle-in-histogram
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████████████████████████████████████████████████████████████████████████████████████████