Daily Temperatures
Write the code, see it run, pass the checks.
The problem
- medium
- Code
Write daysUntilWarmer(temps): temps holds one temperature per day. Return a new array where each day holds how many days you'd wait for a warmer one, or 0 if no later day is warmer. An equal temperature isn't warmer. Don't change temps. For example, daysUntilWarmer([73, 74, 75, 71, 69, 72, 76, 73]) is [1, 1, 4, 2, 1, 1, 0, 0]. The checks include 100,000 days, so looking ahead from every day is too slow.
Your code must pass
- Counts the days until a warmer one
- Returns 0 when no later day is warmer
- Doesn't count an equal temperature as warmer
- Is fast enough for 100,000 days