We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5e91e0e commit 3d10b02Copy full SHA for 3d10b02
1 file changed
live9/test98/문제3/백한결.py
@@ -0,0 +1,18 @@
1
+def solution(prices):
2
+ answer = [0] * len(prices)
3
+
4
+ stack = []
5
6
+ for i, price in enumerate(prices):
7
+ # 가격이 떨어지는 순간을 찾고 그 때까지의 시간을 계산
8
+ while stack and prices[stack[-1]] > price:
9
+ j = stack.pop()
10
+ answer[j] = i - j
11
+ stack.append(i)
12
13
+ # for문이 끝난 후 떨어지지 않은 가격
14
+ while stack:
15
16
+ answer[j] = len(prices) - (j + 1)
17
18
+ return answer
0 commit comments