PythiloLesson 3 of 8 · progress kept in this browser

Resolve pending answers with a monotonic stack

For each temperature, find how many days pass before a strictly warmer day. Keeping all unanswered days on a stack avoids restarting a search for every day. The stack holds indices with non-increasing temperatures. A new warmer day resolves as many pending days as it can, and every index is pushed and popped at most once.

pending = [0, 1]
temperatures = [20, 18, 22]
print(2 - pending[-1])
Your task

Write warmer_days(temperatures). Return the wait to a strictly warmer future temperature for each position, or zero if none arrives. Equal temperatures do not count as warmer.