#C10718. Daily Temperatures
Daily Temperatures
Daily Temperatures
Given a sequence of daily temperatures, your task is to compute for each day how many days you must wait until a warmer temperature occurs. If no such future day exists, output 0 for that day.
More formally, you are given an integer \(n\) representing the number of days and \(n\) integers \(T_1, T_2, \dots, T_n\) representing the daily temperatures. For each day \(i\), determine the smallest positive integer \(k\) such that \(T_{i+k} > T_i\); if no such \(k\) exists, then the answer for that day is 0.
Your program should read input from standard input (stdin) and write output to standard output (stdout).
inputFormat
The first line contains an integer (n), the number of days. The second line contains (n) space-separated integers representing the daily temperatures.
outputFormat
Output a single line with (n) space-separated integers. The (i)-th integer represents the number of days until a warmer temperature occurs. If no warmer day exists, print 0 for that day.## sample
8
73 74 75 71 69 72 76 73
1 1 4 2 1 1 0 0
</p>