Loading problem...
You are given an array of integers representing temperature readings for consecutive days. For each day, you need to determine how many days you must wait until a warmer temperature occurs. If no warmer day exists in the future for a particular day, the answer for that day should be 0.
Specifically, for the temperature on day i, find the smallest positive integer d such that the temperature on day i + d is strictly greater than the temperature on day i. If no such day exists within the array bounds, return 0 for that position.
The result should be an array of the same length as the input, where each element represents the number of days to wait for a warmer temperature at that corresponding position.
temperatures = [73,74,75,71,69,72,76,73][1,1,4,2,1,1,0,0]Day 0 (73°): Next warmer is Day 1 (74°), wait = 1 day. Day 1 (74°): Next warmer is Day 2 (75°), wait = 1 day. Day 2 (75°): Next warmer is Day 6 (76°), wait = 4 days. Day 3 (71°): Next warmer is Day 5 (72°), wait = 2 days. Day 4 (69°): Next warmer is Day 5 (72°), wait = 1 day. Day 5 (72°): Next warmer is Day 6 (76°), wait = 1 day. Day 6 (76°): No warmer day exists, wait = 0. Day 7 (73°): No future day available, wait = 0.
temperatures = [30,40,50,60][1,1,1,0]Each day (except the last) has a warmer temperature the very next day. The last day has no future days, so it returns 0.
temperatures = [30,60,90][1,1,0]Temperatures are strictly increasing. Each day only needs to wait 1 day for a warmer reading, except the final day which has no warmer successor.
Constraints