[LeetCode] 11. Container With Most Water - python

ha·2022년 1월 19일
0

LeetCode

목록 보기
4/21

Python

class Solution:
    def maxArea(self, height: List[int]) -> int:
        start=0
        end=len(height)-1
        answer=0
        
        while start<end:
            volume=min(height[start],height[end]) * (end-start)
            answer=max(answer,volume)
            
            if height[start] > height[end]:
                end-=1
            else:
                start+=1
                
        return answer

0개의 댓글