class Solution {
public int maxArea(int[] height) {
int i = 0;
int j = height.length-1;
int ans = 0;
while(i<j){
ans = height[i]<height[j]?Math.max(ans,(j-i)*height[i++]):Math.max(ans,(j-i)*height[j--]);
}
return ans;
}
}