码迷,mamicode.com
首页 > 其他好文 > 详细

[LeetCode] Container With Most Water

时间:2014-09-07 23:40:15      阅读:233      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   io   ar   div   sp   log   

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

 

[LeetCode] Container With Most Water

标签:style   blog   color   os   io   ar   div   sp   log   

原文地址:http://www.cnblogs.com/yuhaos/p/3960875.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!