Days until a warmer day
Given daily temperatures, find for each day how many days you have to wait until a warmer one, or 0 if none comes. One way: walk the days left to right keeping a stack of days that are still waiting for a warmer day. When a new day arrives, pop every waiting day that is colder than it; for each one popped, the answer is the distance between them. Then push the new day to wait its turn. Days left on the stack at the end get 0.
Write days_until_warmer(temps) that returns the list of waits. Store
positions on the stack, not temperatures, since you need the distances.
days_until_warmer([73, 74, 75, 71, 69, 72, 76, 73]) -> [1, 1, 4, 2, 1, 1, 0, 0]
def days_until_warmer(temps):
...