Two Pointer
O(n)
class Solution {
public int maxArea(int[] height) {
if (height == null || height.length == 0) return 0;
int left = 0, right = height.length - 1;
int max = 0;
while (left < right){
int h = Math.min(height[left], height[right]);
max = Math.max(max, h * (right - left) );
while (left < right && height[left] <= h) left++;
while (left < right && height[right] <= h) right--;
}
return max;
}
}