https://blog.csdn.net/Zolewit/article/details/88863970
SOLUTION:using stack(单调栈)
class Solution {
public int largestRectangleArea(int[] heights) {
int res = 0;
int len = heights.length;
Stack<Integer> stack = new Stack<Integer>();
for(int i=0;i<=len;i++){
int right = (i==len)?0:heights[i];
while(!stack.isEmpty()&&right<heights[stack.peek()]){
int height = heights[stack.pop()];
res = Math.max(res, height*((stack.isEmpty()?i:(i-1-stack.peek()))));
}
stack.push(i);
}
return res;
}
}