题目传送门
class Solution {
public int maxArea(int[] height) {
int left = 0,right = height.length-1; int ret = 0;
while (left < right){
/**
* 暂时的容量
*/
int temp = Math.min(height[left],height[right]) * (right-left);
/**
* 更新容量,找到最大值
*/
ret = Math.max(temp,ret);
/**
*
*/
if(height[left] > height[right]){
right--;
}else {
left++;
}
}
return ret;
}
}