#K45002. Daily Temperatures
Daily Temperatures
Daily Temperatures
Given a list 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, please output 0 for that day.
The problem is defined as follows:
For an input array \( T \) of \( n \) temperatures, construct an output array \( result \) such that for each day \( i \), \( result[i] \) is the number of days until a day with a higher temperature occurs. If no such day exists, \( result[i] = 0 \).
Input Format: The first line contains an integer \( n \), the number of days. The second line contains \( n \) space-separated integers representing daily temperatures.
Output Format: Print \( n \) space-separated integers representing the computed answer.
inputFormat
The input consists of two lines:
- The first line contains an integer \( n \) which is the number of days.
- The second line contains \( n \) space-separated integers representing the temperatures for each day.
outputFormat
Output a single line containing \( n \) space-separated integers. Each integer is the number of days until a warmer temperature occurs; if no warmer day exists, output 0 for that day.
## sample8
73 74 75 71 69 72 76 73
1 1 4 2 1 1 0 0
</p>