Skip to content

Commit

Permalink
Create 739.py
Browse files Browse the repository at this point in the history
  • Loading branch information
chandansgowda authored Jan 31, 2024
1 parent 673a6f3 commit 976dc04
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions 501-1000/739.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Solution:
def dailyTemperatures(self, T: List[int]) -> List[int]:
ans = [0]*len(T)
stack = []

for i,v in enumerate(T):
while stack and stack[-1][1] < v:
index,value = stack.pop()
ans[index] = i - index
stack.append([i,v])

return ans

0 comments on commit 976dc04

Please sign in to comment.