答案:
class Solution {
public int maxArea(int[] height) {
int max = 0;
int left,right;
left = height[0];
right = height[height.length-1];
for(int i=0;i<height.length-1;i++){
if(height[i]<left){
continue;
}
for(int j=height.length-1;j>i;j--){
if(height[j]<right){
continue;
}
int h;
if(height[i]>height[j]){
h=height[j];
}else{
h=height[i];
}
if(h*(j-i)>max){
max = h * (j-i);
left = height[i];
right = height[j];
}
}
}
return max;
}
}
暴力算法.. 效率不高 以后再找更好的方法吧🥺