(int[] height)
| 10 | */ |
| 11 | public class Solution { |
| 12 | public int maxArea(int[] height) { |
| 13 | int l = 0, r = height.length - 1; |
| 14 | int max = 0, h = 0; |
| 15 | while (l < r) { |
| 16 | h = Math.min(height[l], height[r]); |
| 17 | max = Math.max(max, (r - l) * h); |
| 18 | while (height[l] <= h && l < r) ++l; |
| 19 | while (height[r] <= h && l < r) --r; |
| 20 | } |
| 21 | return max; |
| 22 | } |
| 23 | |
| 24 | public static void main(String[] args) { |
| 25 | Solution solution = new Solution(); |