← All problems

Daily Temperatures

Medium stacksmonotonic-stack LeetCode ↗
For each day, how many days until a warmer temperature (0 if none).

Hints (0/3 revealed)

Log in to reveal hints progressively.

Complexity

Time O(n), Space O(n)

Common pitfalls

  • O(n^2) rescanning
  • Using temperatures instead of indices (need distances)

Your solution

Log in to save your code and track progress.