public static int maxArea(int[] height) { int length = height.length; int left=0,right=length-1,max=0,area; while (left<right){ area = Math.min(height[left],height[right])*(right-left); max = Math.max(max,area); if (height[left]>=height[right]){ //最小的值移动,只有找到更大的值,体积才会更大 right--; }else { left++; } } return max; }