Given a list of daily temperatures, return how many days you must wait for a warmer temperature for each day.
You are given an array of integers temperatures, where temperatures[i] is the temperature on day i.
For each day, find out how many days you would have to wait until a warmer temperature appears. If there is no future day with a warmer temperature, the answer for that day is 0.
Return an array answer such that answer[i] is the number of days after day i until a warmer temperature occurs.
The task is to process the array efficiently, especially when the number of days is large.
temperatures.temperatures[i] represents the temperature on day i.answer of the same length.answer[i] is the number of days to wait for a strictly warmer temperature after day i, or 0 if none exists.1 <= temperatures.lengthtemperatures[i] is an integer.Example 1
Input
temperatures = [73,74,75,71,69,72,76,73]
Output
[1,1,4,2,1,1,0,0]
Explanation
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.