We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cfa17d9 commit 2038bd7Copy full SHA for 2038bd7
739-Daily-Temperatures.py
@@ -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