标签:contain href with 代码 距离 两个指针 etc lang min
class Solution {
public int maxArea(int[] height) {
int l = 0, r = height.length - 1;
int ans = 0;
while(l < r) {
ans = Math.max(ans, (r - l) * Math.min(height[l], height[r]));
if(height[l] < height[r]) l++;
else r--;
}
return ans;
}
}
LeetCode11. Container With Most Water
标签:contain href with 代码 距离 两个指针 etc lang min
原文地址:https://www.cnblogs.com/fan-jiaming/p/12791108.html