int max(int a,int b) { return a>=b?a:b;} int min(int a,int b) { return a>=b?b:a;} int maxArea(int* height, int heightSize) { int i = 0; int j = heightSize-1; int area = 0; int dist = 0; int h = 0; while(i<j) { dist = j-i; h = min(height[i],height[j]); area = max(area,dist*h); if(height[i]<height[j]) i++; else j--; } return area; }