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