盛最多水的容器
- 题目描述
- 算法分析
- 编程代码
链接: 盛最多水的容器
题目描述
算法分析
编程代码
class Solution {
public:int maxArea(vector<int>& height) {int left = 0;int right = height.size()-1;int ret = 0;while(left < right){int n = min(height[left],height[right]);ret = max(ret,n * (right - left));if(n == height[left]){left++;}else{right--;}}return ret;}
};