class Solution { public int maxArea(int[] height) { int ans = 0; int left = 0; int right = height.length - 1; while (left < right) { ans = Math.max(ans, getArea(height, left, right)); if (height[left] < height[right]) { left++; } else { right--; } } return ans; } private int getArea(int[] nums, int left, int right) { return (right - left) * Math.min(nums[left], nums[right]); } }
04-09
591
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
04-03
304
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-31
164
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-31
08-30
1664
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)