赞
踩
我不知道将去向何方,但我已在路上! |
---|
时光匆匆,虽未曾谋面,却相遇于斯,实在是莫大的缘分,感谢您的到访 ! |
class Solution:
def dailyTemperatures(self, T: List[int]) -> List[int]:
stack = []
result = [0] * len(T)
for index in range(len(T)):
while stack != [] and T[stack[-1]] < T[index]:
result[stack[-1]] = index - stack[-1]
stack.pop()
stack.append(index)
return(result)
# 执行用时 :620 ms, 在所有 Python3 提交中击败了75.33%的用户
# 内存消耗 :17.5 MB, 在所有 Python3 提交中击败了8.53%的用户
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。