首页 > 其他 > 详细

11. Container With Most Water

时间:2019-04-07 10:15:59      阅读:106      评论:0      收藏:0      [点我收藏+]
        int res = 0;
        int ab = 0;
        for(int i = 0;i < height.length; i++){
            for (int j = i +1; j < height.length; j++){
                ab = Math.min(height[i], height[j])* (j - i);
                res = Math.max(res, ab);
            }
        }
        return res;
        int low = 0, high = height.length - 1 ;
        int res = 0;
        while (low < high){
            int tlo = height[low], thi = height[high];
            int ab = Math.min(tlo, thi) * (high - low);
            res = Math.max(res, ab);
            
            **if (tlo <= thi)**
                **while (low < high && height[low] <= tlo) low++;**
            **else**
                **while (low < high && height[high] <= thi) high--;**
        }
        
        return res;

11. Container With Most Water

原文:https://www.cnblogs.com/whyaza/p/10664064.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!