Daily Temperatures
Medium
Stacks
Array
Stack
Monotonic Stack
Given temperatures, for each day find how many days until warmer. 0 if never.
Constraints
1 ≤ n ≤ 10^5
Examples
Example 1:
Input: 73 74 75 71 69 72 76 73
Output: 1 1 4 2 1 1 0 0
Example 2:
Input: 30 40 50 60
Output: 1 1 1 0
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console