Solution to Largest Rectangle in Histogram by LeetCode

23 Jun


Question name: Largest Rectangle in Histogram

Update on 2014-06-24: Thanks to optimization, the previous solution passed all the tests. But when I met with the question “Maximal Rectangle”, I realized the previous one is not the designed solution. After Google, the following O(N) algorithm is found.

Update on 2014-09-29: By chance, a shorter solution is found.

Leave a Reply

Your email address will not be published. Required fields are marked *

Please put your code into a <pre>YOUR CODE</pre> section. Thanks and Happy Coding!