LeetCode739 每日温度
class Solution:
def dailyTemperatures(self, temperatures: List[int]) -> List[int]:
ans, stack, n = [0] * len(temperatures), [], len(temperatures)
for i in range(n):
while stack and temperatures[stack[-1]] < temperatures[i]:
pos = stack.pop()
ans[pos] = i - pos
stack.append(i)
return ans