本文共 393 字,大约阅读时间需要 1 分钟。
解题思路
解题代码
def dailyTemperatures(self, T: List[int]) -> List[int]: stack = [] result = [_ for _ in T] for index in range(len(T)): while stack and T[index] > T[stack[-1]]: result[stack[-1]] = index - stack[-1] stack.pop() stack.append(index) for ele in stack: result[ele] = 0 return result
分析
时间复杂度: O(n) 空间复杂度: O(n)转载地址:http://pjum.baihongyu.com/