Leed code 11. Container With Most Water
1 public int maxArea(int[] height) { 2 int left = 0, right = height.length - 1; 3 int maxArea = 0; 4 5 while (left < right) { 6 maxArea = Math.max(maxArea, Math.min(height[left], height[right]) 7 * (right - left)); 8 if (height[left] < height[right]) 9 left++; 10 else 11 right--; 12 } 13 14 return maxArea; 15 }
posted on 2017-05-27 13:04 WenjieWangFlyToWorld 阅读(174) 评论(0) 编辑 收藏 举报