Skip to content

Daily Temperatures ​

Daily Temperatures — LeetCode

For each day, find how many days you have to wait until a warmer temperature. A classic monotonic stack problem.

Approach ​

Push each temperature to stack with index. If a new temperature that is higher than the temperature on the top of the stack is found, then pop while a lower temperature is found and calculate the day difference with current temperature. Add this to the list

Remarks ​