# leetcode 11. Container With Most Water-最大容器|双指针

【思路】

public class Solution {
public int maxArea(int[] height) {
int l = 0, r = height.length - 1, res=0;
while(l < r)
res = Math.max(res, (r-l) * (height[l] < height[r] ? height[l++] : height[r--]));
return res;
}
}
45 / 45 test cases passed. Runtime: 4 ms  Your runtime beats 73.09% of javasubmissions.

class Solution(object):
def maxArea(self, height):
"""
:type height: List[int]
:rtype: int
"""
l, r, mArea = 0, len(height)-1, 0
while l < r :
if height[l] < height[r] :
mArea, l = max(mArea, (r-l)*height[l]), l+1
else :
mArea, r = max(mArea, (r-l)*height[r]), r-1
return mArea
45 / 45 test cases passed. Runtime: 84 ms  Your runtime beats 71.06% of pythonsubmissions.

#### LeetCode11. Container With Most Water（思维题：选择左右边使得容器所盛水最多）

2016-11-30 15:31:13

#### LeetCode --- 11. Container With Most Water

2015-01-29 10:49:05

#### [LeetCode][11]Container With Most Water解析 时间复杂度为O(n) -Java实现

2016-06-12 14:16:19

#### LeetCode(11) ContainerWithMostWater

2013-12-09 08:23:48

#### 【LEETCODE】11-Container With Most Water [Python]

2016-01-07 09:03:13

#### Leetcode刷题记——11. Container With Most Water（装最多水的容器）

2016-10-17 14:53:32

#### [LeetCode]Container With Most Water, 解题报告

2013-12-10 19:47:10

#### LeetCode 11 Container With Most Water (C,C++,Java,Python)

2015-05-07 22:56:04

#### [LeetCode] 011. Container With Most Water (Medium) (C++/Java/Python)

2015-03-02 22:51:59

#### 11. 盛最多水的容器 Container With Most Water

2018-03-26 20:13:03