1 public int maxArea(int[] height) { 2 int left = 0, right = height.length - 1; 3 int maxArea = 0; 4 5 while (left < right) { 6 maxArea = Math.max(maxArea, Math.min(height[left], height[right]) 7 * (right - left)); 8 if (height[left] < height[right]) 9 left++;10 else11 right--;12 }13 14 return maxArea;15 }