/**
* @param {number[]} height
* @return {number}
*/
var maxArea = function(height) {
let max=0;
for(let i=0,j=height.length-1;i<j;){
const minHeight=height[i]<height[j]?height[i++]:height[j--];
const area=(j-i+1)*minHeight;
max=Math.max(max,area);
}
return max;
};
【leetcode】盛最多水的容器 双指针
最新推荐文章于 2025-04-29 12:29:58 发布