-
[LeetCode] 11. Container With Most Water알고리즘 2022. 6. 25. 21:57
class Solution: def maxArea(self, height: List[int]) -> int: ret = 0 n = len(height) left = 0 right = n - 1 while (left < right): ret = max(ret, min(height[left], height[right]) * (right - left)) if (height[left] <= height[right]): left += 1 else: right -= 1 return ret
O(N)
two pointer
'알고리즘' 카테고리의 다른 글
[Python] heapq maxheap 메서드 종류 및 사용 (0) 2022.06.24 [LeetCode] 1354. Construct Target Array With Multiple Sums (0) 2022.06.24 [LeetCode] 90. Subsets II (0) 2022.06.22 [LeetCode] 438. Find All Anagrams in a String (0) 2022.06.21 Manacher's Algorithm [가장 긴 펠렌드롬 찾기] (0) 2022.06.20