Leetcode - 11 Container With Most Water (Medium)
题目描述:找出两条线,使得构成的容器能够容纳最多的水。
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;
}