A traveller is planning a trip and reads the weather forecast of a city. The list temperatures gives the forecast for each coming day.
For every day, count how many days she must wait to reach a day that is strictly hotter. Write that count at the same position in the answer. If no later day is hotter, write 0.
Examples
Example 1:
Input: temperatures = [41,35,48,38,34,52,43]
Output: [2,1,3,2,1,0,0]
Explanation: Day 0 (41) must wait 2 days for 48. Day 2 (48) must wait 3 days for 52. The last two days have no hotter day after them.
Example 2:
Input: temperatures = [60,50,40,30]
Output: [0,0,0,0]
Explanation: It only gets colder, so every answer is 0.
Example 3:
Input: temperatures = [70,70,71]
Output: [2,1,0]
Explanation: A day with the same temperature is not hotter. Both of the first two days wait for the 71.