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