My modified answer from GeeksforGeeks, in JAVA
I was stuck and took an eye on Geeks4Geeks. I got the idea and tried to figure it out by myself...\nIt takes me a lot of time to make it through....\n\nEDITED: 
I was stuck and took an eye on Geeks4Geeks. I got the idea and tried to figure it out by myself...\nIt takes me a lot of time to make it through....\n\n**EDITED:** Now it is pretty concise....\n\n    public class Solution {\n    public int largestRectangleArea(int[] height) {\n        if (height==null) return 0;//Should throw exception\n        if (height.length==0) return 0;\n        \n        Stack<Integer> index= new Stack<Integer>();\n        index.push(-1);\n        int max=0;\n        \n        for  (int i=0;i<height.length;i++){\n                //Start calculate the max value\n            while (index.peek()>-1)\n                if (height[index.peek()]>height[i]){\n                    int top=index.pop();                    \n                    max=Math.max(max,height[top]*(i-1-index.peek()));  \n                }else break;\n                \n            index.push(i);\n        }\n        while(index.peek()!=-1){\n        \tint top=index.pop();\n            max=Math.max(max,height[top]*(height.length-1-index.peek()));\n        }        \n        return max;\n    }\n}
['Java']