LC.P11[盛最多水的容器] 方法一:双指针1234567891011class Solution { public int maxArea(int[] height) { int ans = 0, left = 0, right = height.length - 1; while (left < right) { ans = Math.max(ans, (right - left) * Math.min(height[left], height[right])); if (height[left] < height[right]) ++left; else --right; } return ans; }} 时间复杂度:$O(n)$ 空间复杂度:$O(1)$