Days Until Warmer
For each day in temps, return how many days you must wait for a strictly warmer temperature, or 0 if it never comes.
Requirements
- Run in time with a monotonic stack.
Examples
EXAMPLE WALKTHROUGHclassic
A guided view of the published example, not a trace of your code.
INPUT
[[73,74,75,71,69,72,76,73]]TASKdays_until_warmer()
EXPECTED OUTPUT
[1,1,4,2,1,1,0,0]Start with the input values shown in this example.
Example 1 of 3
Input: temps = [73,74,75,71,69,72,76,73]
Output: [1,1,4,2,1,1,0,0]
Explanation: classic
Input: temps = [30,40,50,60]
Output: [1,1,1,0]
Explanation: rising
Input: temps = [60,50,40]
Output: [0,0,0]
Explanation: falling
Hint 1
Keep a stack of days still waiting for a warmer day.