739. Daily Temperatures
https://leetcode.com/problems/daily-temperatures/
class Solution:
def dailyTemperatures(self, T: List[int]) -> List[int]:
n = len(T)
res = [0] * n
stack = []
for i in range(n):
while stack and T[stack[-1]] < T[i]:
curr = stack.pop()
res[curr] = i - curr
stack.append(i)
return res
Last updated