/**
* 盛最多水的容器-双指针法-LeetCode11
* (时间复杂度O(n),空间复杂度O(1))
*/
class Solution {
public int maxArea(int[] height) {
int maxArea = 0, left = 0, right = height.length - 1;
while (left < right) {
maxArea = Math.max(maxArea, (right - left) * Math.min(height[left], height[right]));
if (height[left] > height[right]) { // 左边大移动右边
right--;
} else {
left++;
}
}
return maxArea;
}
}