class Solution:
def maxArea(self, height):
"""
:type height: List[int]
:rtype: int
"""
ans = 0
l = 0
r = len(height) - 1
while l < r:
w = min(height[l], height[r])
ans = max(ans, w * (r - l))
if height[l] < height[r]:
l += 1
else:
r -= 1
return ans
11. Container With Most Water
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- Given n non-negative integers a1, a2, ..., an, where each...
- 题目 原题链接Given n non-negative integers a1, a2, ..., an, whe...
- 题目:Given n non-negative integers a1, a2, ..., an, where e...
- 题目 Given n non-negative integers a1, a2, ..., an, where e...
- 能够想到的最传统的方法: 相当于将所有的Cn2种情况都遍历了一遍。 样本特别大就没办法啦。会超时的。 那么!时间复...