| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- Convert Sorted List to Binary Search Tree
- data science
- Python Code
- attribute
- 43. Multiply Strings
- kaggle
- concurrency
- 프로그래머스
- 시바견
- 715. Range Module
- 30. Substring with Concatenation of All Words
- Python Implementation
- Generator
- DWG
- Substring with Concatenation of All Words
- 운영체제
- Class
- Regular Expression
- Protocol
- Decorator
- shiba
- 파이썬
- t1
- Python
- LeetCode
- 밴픽
- 컴퓨터의 구조
- 109. Convert Sorted List to Binary Search Tree
- iterator
- 315. Count of Smaller Numbers After Self
Archives
- Today
- Total
Scribbling
프로그래머스: 주식 가격 본문
근본 없는 문제다.
도저히 지문을 이해할 수 없게 적어놨다.
def solution(prices):
answer = [i for i in range(len(prices)-1, -1, -1)]
stack = []
for i in range(len(prices)):
p = prices[i]
if not stack or p >= stack[-1][0]:
stack.append((p, i))
else:
while stack and stack[-1][0] > p:
bef_p, bef_i = stack.pop()
answer[bef_i] = i - bef_i
stack.append((p, i))
return answer'Computer Science > Coding Test' 카테고리의 다른 글
| 프로그래머스: 디스크 컨트롤러 (0) | 2021.10.16 |
|---|---|
| 프로그래머스: 더 맵게 (0) | 2021.10.16 |
| 프로그래머스: 다리를 지나는 트럭 (0) | 2021.10.15 |
| LeetCode: 96. Unique Binary Search Trees (0) | 2021.10.13 |
| LeetCode: 95. Unique Binary Search Trees II (0) | 2021.10.13 |