class Solution {
public int largestRectangleArea(int[] heights) {
int squar = 0;
Stack<Integer> st = new Stack();存储下标
int[] tmp = new int[heights.length+2];
System.arraycopy(heights, 0, tmp, 1, heights.length);
for(int i = 0;i < tmp.length;i++) {
while(!st.isEmpty() && tmp[i] < tmp[st.peek()]) {
int k = tmp[st.pop()];
squar = Math.max(squar, (i-st.peek()-1)*k);
}
st.push(i);
}
return squar;
}
}