#739
Daily Temperatures
pupil · 580 · lc medium +29 · verified · 68.4% accepted · 14,599 likes · top 75%
Description
You are given a daily temperature log as an integer array temperatures. For each day i, compute the minimum number of days you must wait until a strictly warmer day occurs. If no warmer day ever follows, record 0 for that day. Return the resulting array answer.
Example 1:
Input: temperatures = [73,74,75,71,69,72,76,73]
Output: [1,1,4,2,1,1,0,0]
Example 2:
Input: temperatures = [30,40,50,60]
Output: [1,1,1,0]
Example 3:
Input: temperatures = [30,60,90]
Output: [1,1,0]
Code
1
2
3