盛最多水的容器
lzxjack opened this issue · comments
/**
* @param {number[]} height
* @return {number}
*/
var maxArea = function(height) {
let left = 0; right = height.length - 1, max = 0;
while(left < right){
let temp = (right - left) * Math.min(height[left],height[right]) // 长x宽的值
if(temp > max){
max = temp
}
if(height[left] <= height[right]){ //留下长的那一边
left++
}
else{
right--
}
}
return max
};