일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 43. Multiply Strings
- 30. Substring with Concatenation of All Words
- Decorator
- Python Code
- 프로그래머스
- iterator
- Convert Sorted List to Binary Search Tree
- 시바견
- t1
- Python Implementation
- attribute
- 109. Convert Sorted List to Binary Search Tree
- 315. Count of Smaller Numbers After Self
- Protocol
- shiba
- 715. Range Module
- kaggle
- Class
- DWG
- LeetCode
- Generator
- 파이썬
- 밴픽
- Python
- concurrency
- data science
- 컴퓨터의 구조
- Regular Expression
- Substring with Concatenation of All Words
- 운영체제
Archives
- Today
- Total
Scribbling
LeetCode: 11. Container With Most Water 본문
Greedy하게...
class Solution:
def maxArea(self, height: List[int]) -> int:
max_Area = 0
l = 0
r = len(height) - 1
while l < r:
w = r - l
h = min(height[l], height[r])
max_Area = max(max_Area,w*h)
if height[l] < height[r]:
for next_l in range(l+1, len(height)):
if height[next_l] > height[l]:
l = next_l
break
if next_l == len(height) - 1:
break
else:
for next_r in range(r-1, -1, -1):
if height[next_r] > height[r]:
r = next_r
break
if next_r == 0:
break
return max_Area
'Computer Science > Coding Test' 카테고리의 다른 글
LeetCode: 16. 3Sum Closest (0) | 2021.08.21 |
---|---|
LeetCode: 15. 3Sum (0) | 2021.08.19 |
LeetCode: 8. String to Integer (atoi) (0) | 2021.08.16 |
LeetCode: 6. ZigZag Conversion (0) | 2021.08.16 |
LeetCode: 207. Course Schedule (0) | 2021.08.14 |