Leetcode - 11 Container With Most Water (Medium)
题目描述:找出两条线,使得构成的容器能够容纳最多的水。
![](https://i-blog.csdnimg.cn/blog_migrate/f6400b5ef3a13cff76c490ac4e517ec9.png)
public int maxArea(int[] height) {
int max = 0, i = 0, j = height.length - 1;
while (i < j) {
max = Math.max(max, (j - i) * Math.min(height[i], height[j]));
if (height[i] < height[j]) {
i++;
} else {
j--;
}
}
return max;
}