Daily Temperatures
Problem Statement
You are given a list of daily temperatures
, representing the temperature of each day in a sequence. For each day, you want to know the number of days before it will have a higher temperature.
Task
Write a function to return the number of days before each day will have a higher temperature. The result should be an array where
stores the number of days before
will have a higher temperature.
Rules and Constraints
- is an array of integers representing the temperature of each day in a sequence.
- The temperature of each day is represented as an integer in the range .
- The result array should be the same length as .
- Time complexity: The function should run in O(n) time complexity where n is the length of the array.
- Space complexity: The function should run in O(n) space complexity where n is the length of the array.
Example
Input: {"temperatures":[73,74,75,71,69,72,76,73]}
Output: [1,1,4,2,1,1,0,0]