LeetCode 11. 盛最多水的容器

11. 盛最多水的容器

解题思路

参考代码

1
2
3
4
5
6
7
8
9
10
11
12
class Solution {
public int maxArea(int[] height) {
int res = 0;
int left = 0, right = height.length - 1;
while(left < right) {
res = Math.max(res, Math.min(height[left], height[right]) * (right - left));
if(height[left] <= height[right]) left ++;
else right --;
}
return res;
}
}

LeetCode 11. 盛最多水的容器
https://sowink.cn/2026/02/08/LeetCode-11-盛最多水的容器/
作者
Xurx
发布于
2026年2月8日
许可协议