dsa · medium
Daily Temperatures
temperatures[i] is the forecast in °C on day i. For each day return the number of days until a **warmer** reading. Use 0 when no later day is warmer.
Arguments
temperatures— daily °C; for each day, days until a strictly warmer day
Example
[73,74,75,71,69,72,76,73] → [1,1,4,2,1,1,0,0].
[30,40,50,60] → [1,1,1,0].
[30,60,90] → [1,1,0].
Constraints
1 <= temperatures.length <= 10^5 30 <= temperatures[i] <= 100 Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.
Examples
Example 1
Input: [73,74,75,71,69,72,76,73] Expected: [1,1,4,2,1,1,0,0]
Example 2
Input: [30,40,50,60] Expected: [1,1,1,0]
Example 3
Input: [30,60,90] Expected: [1,1,0]