Share my 2ms Java solution. Beats 100% Java submissions
public class Solution {\n        public int largestRectangleArea(int[] heights) {\n            if (heights == null || heights.length == 0) return 0;\n          
    public class Solution {\n        public int largestRectangleArea(int[] heights) {\n            if (heights == null || heights.length == 0) return 0;\n            return getMax(heights, 0, heights.length);\n        }    \n        int getMax(int[] heights, int s, int e) {\n            if (s + 1 >= e) return heights[s];\n            int min = s;\n            boolean sorted = true;\n            for (int i = s; i < e; i++) {\n                if (i > s && heights[i] < heights[i - 1]) sorted = false;\n                if (heights[min] > heights[i]) min = i;\n            }\n            if (sorted) {\n                int max = 0;\n                for (int i = s; i < e; i++) {\n                    max = Math.max(max, heights[i] * (e - i));\n                }\n                return max;\n            }\n            int left = (min > s) ? getMax(heights, s, min) : 0;\n            int right = (min < e - 1) ? getMax(heights, min + 1, e) : 0;\n            return Math.max(Math.max(left, right), (e - s) * heights[min]);\n        }\n    }
['Java']