일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 715. Range Module
- shiba
- 43. Multiply Strings
- 109. Convert Sorted List to Binary Search Tree
- Decorator
- iterator
- Generator
- 프로그래머스
- 컴퓨터의 구조
- attribute
- Substring with Concatenation of All Words
- concurrency
- Class
- 밴픽
- t1
- LeetCode
- Regular Expression
- 315. Count of Smaller Numbers After Self
- 파이썬
- 시바견
- Protocol
- DWG
- 운영체제
- 30. Substring with Concatenation of All Words
- data science
- Python Implementation
- Python Code
- Convert Sorted List to Binary Search Tree
- Python
- kaggle
Archives
- Today
- Total
목록42. Trapping Rain Water (1)
Scribbling
LeetCode: 42. Trapping Rain Water
The key observations to solve this problems: - right >= left + 2, to contain water - if we have a max height either at left or right position, then we can calculate water in the opposite position. class Solution: def trap(self, height: List[int]) -> int: ret = 0 l, r = 0, len(height) - 1 leftmax, rightmax = height[l], height[r] while r - l >= 2: curmax = max(leftmax, rightmax) if curmax == right..
Computer Science/Coding Test
2021. 9. 12. 23:20