Leetcode 11. 盛最多水的容器-双指针
作者:互联网
代码:
class Solution { public: int maxArea(vector<int>& height) { int L = 0,R = height.size()-1; int max_Area = 0; while(L<R) { int ans_area = min(height[L],height[R])*(R-L); max_Area = max(max_Area,ans_area); if(height[L]<height[R]) { L++; } else{ R--; } } return max_Area; } };
标签:11,Area,int,max,height,最多水,Leetcode,size 来源: https://www.cnblogs.com/gcter/p/15467049.html