11. Container With Most Water

202401181639
tags: #two-pointers

class Solution(object):
	def maxArea(self, height):
		res = 0
		start = 0
		end = len(height) - 1
		while start < end:
			w = end - start
			h = min(height[start], height[end])
			area = w * h
			res = max(res, area)
			if height[start] < height[end]:
				start += 1
			else:
				end -= 1
		return res

Reference

https://leetcode.com/problems/container-with-most-water/