Limits: 1s, 512 MB
The Great Sofdor Ali is now interested in competitive programming. Seeing this, his friend and also a renowned scientist Anik Lumba gave him a problem. The problem statement is simple. You have a non-decreasing histogram. You have to find the area of largest rectangle contained within the histogram. For example, in the histogram below, where the 6 bars have heights 1 2 2 4 5 7, the area colored in red is the largest rectangle contained by the histogram. The area of this rectangle is 12.
This is a companion discussion topic for the original entry at https://toph.co/p/sofdor-ali-and-histogram