题目: 思路: 动态规划,双指针。 代码: class Solution { public: int maxArea(vector<int>& height) { int res=0; int i=0,j=height.size()-1; int h=0; while(i<j) { h=min(height[i],height[j]);//找到最小的柱子 res=max(res,h*(j-i));//返回每次最大的面积 if(height[i]>height[j]) { j--; } else { i++; } } return res; } };