其他分享
首页 > 其他分享> > 11. 盛最多水的容器

11. 盛最多水的容器

作者:互联网

11. 盛最多水的容器

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

..

标签:11,容器,end,area,int,max,height,start,最多水
来源: https://www.cnblogs.com/guoyu1/p/15718780.html