11. Container With Most Water

class Solution {
    public int maxArea(int[] height) {
        int maxArea=0;
        int i=0;
        int j=height.length-1;
        while(i<j)
        {
            maxArea=Math.max(maxArea,Math.min(height[i],height[j])*(j-i));
            if(height[i]<height[j])
                i++;
            else
                j--;
        }
        return maxArea;
    }
}

  

posted @ 2017-09-22 11:23  Weiyu Wang  阅读(128)  评论(0编辑  收藏  举报