#K92587. Daily Temperatures

    ID: 38230 Type: Default 1000ms 256MiB

Daily Temperatures

Daily Temperatures

You are given a list of daily temperatures. For each day, you need to determine how many days you would have to wait until a warmer temperature. If there is no future day for which this is possible, store 0 for that day.

The solution should be efficient using a monotonic stack approach. In other words, you will process the temperatures and, for every temperature, find the next day that has a higher temperature. Mathematically, if T is the array of temperatures (with indices \(0 \leq i T[i] \\ 0, & \text{if no such } j \text{ exists} \end{cases} \] where \(j > i\). This task is common in coding competitions and tests your ability to use stack data structures effectively.

inputFormat

The first line contains a single integer n representing the number of days (temperatures). The second line contains n space-separated integers representing the daily temperatures.

outputFormat

Output a single line containing n space-separated integers representing the number of days until a warmer temperature. If no future day is warmer, output 0 for that day.

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