1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| public static int maxArea(int[] height) { int res = 0; for (int l = 0, r = height.length-1;l<r; ) { int are = Math.min(height[l], height[r]) * (r - l); res = Math.max(are, res); if (height[l] < height[r]) { l++;
} else { r--; } } return res; }
|