```
public class Solution {
public int maxArea(int[] height) {
int left = 0;
int right = height.length - 1;
int res = 0;
while(left < right){
res = Math.max(res, Math.min(height[right], height[left]) * (right - left));
if(height[right] < height[left])
right--;
else
left++;
}
return res;
}
}
```