Daily Temperatures
Problem Statement
You are given a list of daily temperatures
temperaturesTask
Write a function to return the number of days before each day will have a higher temperature. The result should be an array where
result[i]temperatures[i]Rules and Constraints
- is an array of integers representing the temperature of each day in a sequence.
temperatures - The temperature of each day is represented as an integer in the range .
[32, 123] - The result array should be the same length as .
temperatures - Time complexity: The function should run in O(n) time complexity where n is the length of the array.
temperatures - Space complexity: The function should run in O(n) space complexity where n is the length of the array.
temperatures
Example
Input: {"temperatures":[73,74,75,71,69,72,76,73]} Output: [1,1,4,2,1,1,0,0]
CompaniesAmazon
JavaScript
Login to write code
Solve problems, verify your skills, and earn XP.