#C2995. Daily Temperatures
Daily Temperatures
Daily Temperatures
You are given a list of daily temperatures. For each day, determine the number of days until a warmer temperature occurs. If there is no future day for which this is possible, output 0 for that day.
For example, given the temperatures [73, 74, 75, 71, 69, 72, 76, 73], the answer is [1, 1, 4, 2, 1, 1, 0, 0].
Note: The input is provided as a list of integers representing temperatures over consecutive days. The problem requires an efficient solution that can handle large inputs (up to 10^5 days). Use the standard input (stdin) for reading input and standard output (stdout) for printing the result. Any formulas should be formatted in LaTeX, for example, represents the number of days.
inputFormat
The first line contains an integer , the number of days. The second line contains space-separated integers representing the daily temperatures.
outputFormat
Print a single line with space-separated integers where the -th integer is the number of days until a warmer temperature occurs for day . If no such day exists, print 0 for that position.## sample
8
73 74 75 71 69 72 76 73
1 1 4 2 1 1 0 0