LeetCode11:Container With Most Water

 public int MaxArea(int[] height) {
     int start=0;
            int end=height.Length-1;
        
            int max=0;
            
            while(start<end)
            {
                max=Math.Max(max,Math.Min(height[start],height[end])*(end-start));
                if(height[start]<height[end])
                    start++;
                else
                    end--;
            }
            
            return max;
    }

 

posted @ 2015-09-05 20:32  darksied  阅读(119)  评论(0编辑  收藏  举报