```
public int maxArea(int[] height) {
int maxA = 0;
int i = 0, j = height.length-1;
while(i < j) {
int H = Math.min(height[i], height[j]);
int W = j - i;
maxA = Math.max(maxA, H*W);
while(i < j && height[i] <= H) {
++i;
}
while(i < j && height[j] <= H) {
--j;
}
}
return maxA;
}
```