Skip to content

Commit 2038bd7

Browse files
authored
Create 739-Daily-Temperatures.py
1 parent cfa17d9 commit 2038bd7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

739-Daily-Temperatures.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution:
2+
def dailyTemperatures(self, temperatures: List[int]) -> List[int]:
3+
res = [0] * len(temperatures)
4+
stack = [] # pair: [temp, index]
5+
6+
for i, t in enumerate(temperatures):
7+
while stack and t > stack[-1][0]:
8+
stackT, stackInd = stack.pop()
9+
res[stackInd] = (i - stackInd)
10+
stack.append([t, i])
11+
return res

0 commit comments

Comments
 (0)