更新 0739.每日温度.md Python3代码

This commit is contained in:
lichun-chen
2021-07-07 20:47:03 -05:00
committed by GitHub
parent b4d2f98bc7
commit c369db528f

View File

@ -211,7 +211,24 @@ Java
}
```
Python
''' Python3
class Solution:
def dailyTemperatures(self, temperatures: List[int]) -> List[int]:
answer = [0]*len(temperatures)
stack = [0]
for i in range(1,len(temperatures)):
# 情况一和情况二
if temperatures[i]<=temperatures[stack[-1]]:
stack.append(i)
# 情况三
else:
while len(stack) != 0 and temperatures[i]>temperatures[stack[-1]]:
answer[stack[-1]]=i-stack[-1]
stack.pop()
stack.append(i)
return answer
'''
Go
> 暴力法