ntree.ai
ntree.aiDaily Temperatures

Daily Temperatures

mediumsolvedattempted

You are given an array of temperatures, where temperatures[i] is the temperature on day i.

Return an array answer where answer[i] is the number of days to wait for a warmer day after day i.

If no warmer day comes, put 0.

Example 1:

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

Constraints:

  • 1 <= length of temperatures <= 10^5
  • -100 <= temperatures[i] <= 100
def dailyTemperatures(temperatures: list[int]) -> list[int]:
pass
 

Press Visualise to step through your code.