#K3266. Daily Temperatures

    ID: 24921 Type: Default 1000ms 256MiB

Daily Temperatures

Daily Temperatures

Given an array of daily temperatures, your task is to determine for each day how many days you would have to wait until a warmer temperature. If there is no future day for which this is possible, output 0 for that day.

The challenge is to implement an efficient solution using stacks to avoid unnecessary comparisons. The algorithm should run in O(n) time complexity. The answer for a day i is the difference between the indices of the first day with a hotter temperature > temperatures[i] and i, or 0 if no such day exists.

Note: The input is provided via stdin and the output should be written to stdout. Use space separated integers for both input and output.

Example:

Input:
8
73 74 75 71 69 72 76 73

Output: 1 1 4 2 1 1 0 0

</p>

inputFormat

The first line of input contains a single integer n representing the number of days. The second line contains n space-separated integers, where each integer represents the temperature on that day.

For instance:

8
73 74 75 71 69 72 76 73

outputFormat

Output a single line of n space-separated integers, where the i-th integer is the number of days you have to wait after day i for a warmer temperature. If there is no such day, output 0 for that day.

## sample
8
73 74 75 71 69 72 76 73
1 1 4 2 1 1 0 0