public int maxArea(int[] height) {
        int max = 0;
        if (height == null || height.length < 2) {
            return max;
        }

        int left = 0;
        int right = height.length - 1;
        while (left < right) {
            int tmax = (right - left) * Math.min(height[left], height[right]);
            if (tmax > max) {
                max = tmax;
            }

            if (height[left] < height[right]) {
                int t = left;
                while (t < right && height[t] <= height[left]) {
                    t++;
                }
                left = t;
            } else {
                int t = right;
                while (t > left && height[t] <= height[right]) {
                    t--;
                }
                right = t;
            }
        }

        return max;
    }