Create Largest Rectangle in Histogram

cost me 2 hours to solve