Skip to content

Commit 719967f

Browse files
committed
[PGS] 주식가격 / Level 2 / 40분 / 성공
1 parent b58a650 commit 719967f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def solution(prices):
2+
answer = [0] * len(prices)
3+
stack = []
4+
5+
for idx, p in enumerate(prices):
6+
while stack and (p < prices[stack[-1]] or idx == len(prices) - 1):
7+
last = stack.pop()
8+
answer[last] = idx - last
9+
stack.append(idx)
10+
11+
return answer

0 commit comments

Comments
 (0)