Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

盛最多水的容器 #360

Open
lzxjack opened this issue Jan 11, 2023 · 1 comment
Open

盛最多水的容器 #360

lzxjack opened this issue Jan 11, 2023 · 1 comment

Comments

@lzxjack
Copy link
Contributor

lzxjack commented Jan 11, 2023

No description provided.

@lxy-Jason
Copy link
Contributor

/**
 * @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
};

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants