#K7266. 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 occurs.
If no future day has a warmer temperature, the answer for that day should be 0.
The solution involves efficient use of a stack to track indices and perform comparisons, resulting in an overall time complexity of \(O(n)\), where \(n\) is the number of days.
inputFormat
The first line contains an integer \(n\) representing the number of days.
The second line contains \(n\) space-separated integers, where each integer represents the temperature of a day.
outputFormat
Output a single line containing \(n\) space-separated integers. The \(i\)-th integer should denote the number of days you have to wait until a warmer temperature. If there is no future day with a warmer temperature, output 0 for that day.
## sample8
73 74 75 71 69 72 76 73
1 1 4 2 1 1 0 0