MCPcopy Create free account
hub / github.com/HuberTRoy/leetCode / maxArea

Method maxArea

Array/ContainerWithMostWater.py:141–157  ·  view source on GitHub ↗

:type height: List[int] :rtype: int

(self, height)

Source from the content-addressed store, hash-verified

139"""
140class Solution(object):
141 def maxArea(self, height):
142 """
143 :type height: List[int]
144 :rtype: int
145 """
146 l, r = 0, len(height)-1
147
148 currentMax = 0
149
150 while l != r:
151 currentMax = max(min(height[r], height[l]) * (r-l), currentMax)
152 if height[r] > height[l]:
153 l += 1
154 else:
155 r -= 1
156
157 return currentMax

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected