StackMonotonic StackArray
Given the temperature of each day, report for every day how many days you must wait until a warmer temperature. If no future day is warmer, report 0.
Input
Line 1: n. Line 2: n daily temperatures.
Output
Print n integers: the number of days to wait for each day.
Constraints
1 <= n <= 10^5 30 <= temperature <= 100
Example 1
Input
8 73 74 75 71 69 72 76 73
Output
1 1 4 2 1 1 0 0
Day 0 waits 1 day (74), day 2 waits 4 days (76), the last day never gets warmer.