Skip to interview prep
Apexed

47. Daily Temperatures

MediumStack

For each day in temps, return how many days you must wait for a warmer temperature, or 0 if none comes.

Example 1

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

Constraints

  • 1 ≤ temps.length ≤ 10⁵

Tab indents · Ctrl/⌘ + Enter runs · Esc then Tab leaves the editor

Run checks these cases; the expected output comes from the reference solution. Submit judges all 4 hidden and sample tests.

Code runs only in your browser in an isolated sandbox. Progress and submissions are saved on this device.

Daily Temperatures — coding interview practice — Apexed