← Practice · Stack

Daily Temperatures Medium

Given an array temperatures, return an array answer where answer[i] is the number of days after day i until a strictly warmer temperature occurs. If there is no such day, answer[i] is 0.

Examples

  • [73,74,75,71,69,72,76,73] -> [1,1,4,2,1,1,0,0]
  • [30,40,50,60] -> [1,1,1,0]

Define a function named dailyTemperatures in JavaScript.

00:00▶ Visualize

JavaScript · Tab indents · Ctrl/⌘+Enter runs the tests