链接: https://oj.leetcode.com/problems/container-with-most-water/
尺取法,从两端向中间缩进
class Solution { public: int maxArea(vector<int> &height) //尺取法 { int L=0; int R=height.size()-1; int ans=0; while(L<R) { int tem=min(height[L],height[R]); if(tem*(R-L)>ans) ans=tem*(R-L); if(height[L]<height[R]) L++; else R--; } return ans; } };