1、简单做法,分别从两端去找比它大的第一个点,并且在寻找的过程中做一定的限制。
class Solution {
public:
int maxArea(vector<int>& height) {
int thesize=height.size();
int max=0,other;
for(int i=0;i<thesize;++i)
{
other=thesize-1;
while(height[other]<height[i]&&(other-i)*height[i]>max) --other;
if((other-i)*height[i]>max) max=(other-i)*height[i];
other=0;
while(height[other]<height[i]&&(i-other)*height[i]>max) ++other;
if((i-other)*height[i]>max) max=(i-other)*height[i];
}
return max;
}
};