Next Warmer Day
You are given a list temps of daily temperatures. For each day, find how many days you would have to wait for a strictly warmer day. If no warmer day follows, the answer for that day is 0.
Return the answers as a list, one per day.
Examples
temps = [20, 22, 21, 19, 25, 18] → [1, 3, 2, 1, 0, 0]
temps = [10, 11, 12] → [1, 1, 0]
temps = [40, 30, 50] → [2, 1, 0]On day 1 it is 22; the next warmer day is day 4, at 25, three days later.
Constraints
- Between 1 and 100,000 days, each between −100 and 100 degrees.
- Aim for O(n): each day should enter and leave your bookkeeping once.
Console
›Run to see what your code prints
Run checks the 3 visible cases here, in your browser. Submit runs all 6 on the judge, 3 of them hidden, and measures how your solution scales.
Expected is the reference solution's answer, from the judge. An input that breaks the statement's other rules may get any answer.