Create largest Rectangle in Histogram 

Very similar to longest valid parentheses. Stack to store the position of each histogram that can reach. When reach right end, we need to calculate all the histogram that can't pass this right end. when calculating area, left end should be the position of previous position in the stack. When the stack is empty, mean the current histogram is the lowest histogram to current right end.