您的位置:首页 > 大数据 > 人工智能

11. Container With Most Water

2017-04-01 12:25 447 查看


变量唯一

public class Solution {
public int maxArea(int[] height) {
int n = height.length;
int max_Area = 0;
int left = 0;
int right = n-1;
while (left < right) {
max_Area = Math.max(max_Area, Math.min(height[left], height[right]) * (right - left));
if(height[left] <= height[right]) ++left;
else --right;
}
return max_Area;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: