@@ -0,0 +1,998 @@
+// Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.%0A%0A%0A// Above is a histogram where width of each bar is 1, given height = %5B2,1,5,6,2,3%5D.%0A%0A%0A// The largest rectangle is shown in the shaded area, which has area = 10 unit.%0A%0A// For example,%0A// Given height = %5B2,1,5,6,2,3%5D,%0A// return 10.%0A%0Apublic class Solution %7B%0A    public int largestRectangleArea(int%5B%5D heights) %7B%0A        int len = heights.length;%0A        if(len == 0) return len;%0A%0A        Stack%3CInteger%3E st = new Stack%3CInteger%3E();%0A        int max = 0;%0A%0A        for(int i = 0; i %3C= len; i++)%7B%0A        %09int current = (i == len)? -1 : heights%5Bi%5D;%0A        %09while(!st.isEmpty() && current %3C heights%5Bst.peek()%5D)%7B%0A        %09%09int height = heights%5Bst.pop()%5D;%0A        %09%09int width = st.isEmpty()? i : i - st.peek() - 1;%0A        %09%09max = max %3C (height * width)? height * width : max;%0A        %09%7D%0A%0A        %09st.push(i);%0A        %7D%0A%0A        return max;%0A    %7D%0A%7D

add largest rectangle in histogram solution