Skip to content

Commit

Permalink
Daily Temperatures
Browse files Browse the repository at this point in the history
  • Loading branch information
rinwf committed Oct 26, 2018
1 parent a2799b9 commit c6debea
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lc739. Daily Temperatures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class Solution:
def dailyTemperatures(self, T):
"""
:type T: List[int]
:rtype: List[int]
"""
stack = []
res = [0] * len(T)
for i in range(len(T)):
while len(stack) != 0 and T[i] > T[stack[-1]]:
tem = stack.pop()
res[tem] = i - tem
stack.append(i)
return res

0 comments on commit c6debea

Please sign in to comment.