题目描述: 主要思路: 利用双指针的思想,向中间依次移动较低的柱子。 class Solution { public: int maxArea(vector<int>& height) { int i=0,j=height.size()-1; int ans=0; while(i<j) { ans=max(ans,min(height[i],height[j])*(j-i)); if(height[i]<height[j]) ++i; else --j; } return ans; } };