일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 715. Range Module
- 컴퓨터의 구조
- attribute
- 시바견
- DWG
- data science
- shiba
- kaggle
- 109. Convert Sorted List to Binary Search Tree
- iterator
- 밴픽
- Regular Expression
- 프로그래머스
- 43. Multiply Strings
- Decorator
- Python Implementation
- 30. Substring with Concatenation of All Words
- 315. Count of Smaller Numbers After Self
- Protocol
- 파이썬
- Class
- concurrency
- Substring with Concatenation of All Words
- Convert Sorted List to Binary Search Tree
- Python Code
- Python
- LeetCode
- t1
- 운영체제
- Generator
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