public int largestRectangleArea(int[] height) {
        int max = 0, i = 0;
        Stack<Integer> pre = new Stack<Integer>();
        
        while(i <= height.length){
            if(pre.isEmpty() || (i < height.length && height[i] >= height[pre.peek()])){
        		pre.push(i++);
        	} else {
        		int t = pre.pop();
        		max = getMax(max, height[t] * ((pre.isEmpty()) ? i : (i - 1 - pre.peek())));
        	}
        }
        return max;
    }