public class Solution {
public int MaxArea(int[] height) {
var l = 0;
var r = height.Length - 1;
var max = 0;
while(l < r){
var current = Math.Min(height[l], height[r]) * (r - l);
max = Math.Max(max , current);
if(height[l] < height[r]){
l++;
}
else if(height[l] > height[r]){
r--;
}
else{
l++;
r--;
}
}
return max;
}
}版权声明:本文为博主原创文章,未经博主允许不得转载。
LeetCode -- Container With Most Water
原文:http://blog.csdn.net/lan_liang/article/details/49770209