Days Until Warmer

temps[i] is the temperature on day i. Return an array answer where answer[i] is how many days after day i the next strictly warmer day comes, or 0 if no later day is warmer.

Constraints

  • 1 ≤ length of temps ≤ 10,000
  • 30 ≤ temps[i] ≤ 100

Example 1

Input
temps = [73,74,75,71,69,72,76,73]
Output
[1,1,4,2,1,1,0,0]
Why:

After day 2 (75) the next warmer day is day 6 (76), four days later.

Example 2

Input
temps = [30,40,50,60]
Output
[1,1,1,0]
Why:

Every day is warmer than the one before.

Example 3

Input
temps = [60,50,40]
Output
[0,0,0]
Why:

It only gets colder.

Hints

    Was this a good challenge?

    Solved by
    0
    Submissions
    0
    Accepted
    –