public class Solution {
public int maxArea(int[] height) {
    int left = 0, right = height.length - 1;
    int maxArea = 0;

    while (left < right) {
        maxArea = Math.max(maxArea, Math.min(height[left], height[right]) * (right - left));
        if (height[left] < height[right])
            left++;
        else
            right--;
    }

    return maxArea;
}

}

相关文章:

  • 2021-11-21
  • 2022-01-06
  • 2021-12-26
  • 2021-10-23
  • 2022-03-03
  • 2021-06-10
  • 2021-09-01
猜你喜欢
  • 2022-01-20
  • 2022-03-01
  • 2021-08-03
  • 2022-12-23
  • 2021-08-03
  • 2021-09-06
  • 2022-02-28
相关资源
相似解决方案