#K52097. Temperature Fluctuations
Temperature Fluctuations
Temperature Fluctuations
Given the daily temperatures of a month, your task is to determine the number of days you have to wait until a warmer temperature occurs. For each day (i), you need to find the smallest day (j) such that (j > i) and (T_j > T_i) (where (T_i) denotes the temperature on day (i)). If there is no future day with a higher temperature, output 0 for that day.
The input begins with an integer (n) representing the number of days, followed by (n) space-separated integers denoting the temperatures. Your output should be a single line containing (n) integers separated by spaces, where the (i)th integer corresponds to the number of days to wait for a warmer temperature for day (i).
inputFormat
The first line of input contains an integer (n) ((1 \leq n \leq 10^4)), the number of days. The second line contains (n) space-separated integers representing the daily temperatures.
outputFormat
Output a single line with (n) space-separated integers. The (i)th integer indicates the number of days until a warmer temperature appears for day (i). If there is no such day, output 0.## sample
8
73 74 75 71 69 72 76 73
1 1 4 2 1 1 0 0