Daily Temperatures

Medium

For every day in temperatures, return how many days you have to wait for a warmer temperature. If no warmer day comes, the value is 0.

Example 1

dailyTemperatures()
Input
temperatures = [73,74,75,71,69,72,76,73]
Output
[1,1,4,2,1,1,0,0]

Example 2

dailyTemperatures()
Input
temperatures = [30,40,50,60]
Output
[1,1,1,0]
Constraints
1 <= temperatures.length <= 10^5
30 <= temperatures[i] <= 100

Topics

ArraysStackMonotonic Stack

Implement dailyTemperatures in the editor and return the answer — printing it is never graded.