@@ -0,0 +1,1076 @@
+package leetcode.largest_rectangle_in_histogram;%0A%0Aimport java.util.Stack;%0A%0A%0Apublic class Solution %7B%0A%09public static class Histogram%7B%0A%09%09int offset, height;%0A%09%09public Histogram(int offset, int height)%7B%0A%09%09%09this.offset = offset;%0A%09%09%09this.height = height;%0A%09%09%7D%0A%09%7D%0A    public int largestRectangleArea(int%5B%5D height) %7B%0A    %09Stack%3CHistogram%3E stack = new Stack%3CHistogram%3E();%0A    %09int length = height.length;%0A    %09int max = 0;%0A    %09for(int i = 0; i %3C length; i++)%7B%0A    %09%09int left = i;%0A    %09%09while(!stack.isEmpty() && stack.peek().height %3E= height%5Bi%5D)%7B%0A    %09%09%09Histogram hist = stack.pop();%0A    %09%09%09int area = hist.height * (i - hist.offset);%0A    %09%09%09left = hist.offset;%0A    %09%09%09if(area %3E max) max = area;%0A    %09%09%7D%0A    %09%09stack.push(new Histogram(left, height%5Bi%5D));%0A    %09%7D%0A    %09while(!stack.isEmpty())%7B%0A%09%09%09Histogram hist = stack.pop();%0A%09%09%09int area = hist.height * (length - hist.offset);%0A%09%09%09if(area %3E max) max = area;%0A    %09%7D%0A    %09return max;%0A    %7D%0A    public static void main(String%5B%5D args)%7B%0A    %09System.err.println(new Solution().largestRectangleArea(new int%5B%5D%7B1,1,1,1,1,2,9,8,8, 5, 5%7D));%0A    %7D%0A%7D%0A

Add java solution for 84. Largest Rectangle in Histogram