public class Solution {
public int maxArea(int[] height) {
/* int max=0;
int len=height.length;
for(int i=0;i<len;i++){
int tmp=0;
// int maxl=0;
/* for(tmp=i+1;tmp<len;tmp++){
if(max<=(tmp-i)*(height[i]<=height[tmp]?height[i]:height[tmp])){
max=(tmp-i)*(height[i]<=height[tmp]?height[i]:height[tmp]);
}
}*/
/* for(;tmp<len;tmp++){
if(height[tmp]>=height[i]){
if(tmp>=i)
maxl=maxl>(tmp-i)?maxl:(tmp-i);
else
maxl=maxl>(i-tmp)?maxl:(i-tmp);
}
}
max=max>maxl*height[i]?maxl:maxl*height[i];
}*/
int len = height.length, low = 0, high = len -1 ;
int maxArea = 0;
while (low < high) {
maxArea = Math.max(maxArea, (high - low) * Math.min(height[low], height[high]));
if (height[low] < height[high]) {
low++;
} else {
high--;
}
}
return maxArea;
}
}