Daily Temperatures

medium · monotonic-stack, array

Daily Temperatures

Given a list of daily temperatures, return a list where each element indicates how many days you would have to wait until a warmer temperature. If there is no future day for which this is possible, put 0.

Function signature

func DailyTemperatures(temps []int) []int

Example

temps = [73,74,75,71,69,72,76,73]
output = [1,1,4,2,1,1,0,0]

Constraints

  • 1 <= len(temps) <= 200_000

Notes

  • Use a monotonic decreasing stack of indices.
Run tests to see results
No issues detected