Notice Period

Warmer-Day Wait

medium

A weather app shows daily highs and wants a little badge on each day: "warmer in N days."

Given temps, a list of daily temperatures in order, return a list wait where wait[i] is the number of days after day i until a strictly warmer day arrives. If no warmer day ever comes, wait[i] = 0.

Example 1
in temps = [73, 74, 75, 71, 69, 72, 76, 73]
out [1, 1, 4, 2, 1, 1, 0, 0]
Day 2 (75°) waits 4 days for 76°. The last 76° and 73° never see warmer.
Example 2
in temps = [30, 40, 50, 60]
out [1, 1, 1, 0]
Example 3
in temps = [30, 60, 90]
out [1, 1, 0]
Constraints
  • · 1 <= len(temps) <= 10^5
  • · 30 <= temps[i] <= 100
similar problem on LeetCode ↗
solution.pyloading python…
test results
Hit ▶ Run to test your code against the visible cases.