1 int maxArea(vector<int>& height) { 2 int left,right,Max =-9999; 3 for(left = 0,right = height.size() - 1;left < right;) 4 { 5 Max = max(Max,(right - left)*min(height[left],height[right])); 6 height[left]<height[right]?left++:right--; 7 } 8 return Max; 9 }
leetcode 138:container-with-most-water
原文:https://www.cnblogs.com/qingjiaowoxiaoxioashou/p/13490241.html