Daily temperatures
A list temps holds one temperature reading per day, in day order. For each day, look ahead for the first later day with a strictly higher reading, and report how far ahead it is: 1 if it is the next day, 2 if it is the day after that, and so on. A reading equal to that day's does not count. If no later reading is higher, report 0.
Return a list of these numbers, one per day, in day order.
temps = [70, 68, 72, 71, 75]Output[2, 1, 2, 1, 0]Day 0 (70) waits until day 2 (72), which is 2 days. Day 2 (72) waits until day 4 (75). Nothing comes after day 4.
temps = [50, 40, 50, 60]Output[3, 1, 1, 0]Day 2 is as warm as day 0, not warmer, so day 0 waits until day 3.
temps = [65, 60, 55]Output[0, 0, 0]It only gets colder, so no day ever sees a warmer one.
1 ≤ len(temps) ≤ 105
30 ≤ temps[i] ≤ 100
Plan it first
Write a line for each before you code, then say them out loud. Compare with the Approach tab afterwards.