temps[i] is the temperature on day i. For each day, return how many days you must wait until a warmer day; return 0 if there is no warmer day later.
For [73, 74, 75, 71, 69, 72, 76, 73] the answer is [1, 1, 4, 2, 1, 1, 0, 0].
The starter code looks ahead from every day. It is correct but too slow for long lists.
Example 1
Input:
daily_temperatures([73, 74, 75, 71, 69, 72, 76, 73])
Output:
[1, 1, 4, 2, 1, 1, 0, 0]
Example 2
Input:
daily_temperatures([30, 40, 50, 60])
Output:
[1, 1, 1, 0]
0 <= len(temps) <= 20000030 <= temps[i] <= 100No results yet
Run your code to check it against the examples, or submit to run every test.