Sobes.tech
Junior — Senior

Counting days until a higher temperature

livecode

Task condition

Given an array of integers temps, representing the temperatures for each day. The task is to create an array result, where result[i] is the number of days you need to wait after the i-th day to encounter a day with a higher temperature. If there is no such day, the value should be 0.

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