Skip to content
This repository was archived by the owner on Apr 20, 2024. It is now read-only.

Commit d1852d2

Browse files
committed
created solution for problem74
1 parent 1631cd6 commit d1852d2

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

problem74/Solution.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution:
2+
def dailyTemperatures(self, temperatures: List[int]) -> List[int]:
3+
stack = []
4+
answer = [0] * len(temperatures)
5+
6+
for i, temp in enumerate(temperatures):
7+
while stack and temperatures[stack[-1]] < temp:
8+
index = stack.pop()
9+
answer[index] = i - index
10+
11+
stack.append(i)
12+
13+
return answer

0 commit comments

Comments
 (0)