Diwali Offer!Flat 20% OFF
Enroll Now
PrakalpanaLive online tech training

87. Daily Temperatures

MediumDay 25 of 60Stack & Queue

Given an array temperatures of daily temperatures, return an array answer where answer[i] is the number of days you have to wait after day i to get a strictly warmer temperature. If no warmer day comes later, answer[i] is 0.

Example 1
Input: temperatures = [73,74,75,71,69,72,76,73]
Output: [1,1,4,2,1,1,0,0]
After 75 on day 2, the next warmer day is 76 on day 6, so the wait is 4.
Example 2
Input: temperatures = [30,60,90]
Output: [1,1,0]
Constraints
  • 1 <= temperatures.length <= 10^5
  • 30 <= temperatures[i] <= 100
Hints
Frequently asked at: Amazon, Meta, Google, Uber
Ctrl + Enter runs the examples

Not sure what to learn next?

A 1-on-1 session with an industry mentor and a roadmap built for you. How it works

  1. 1Discuss your goals
  2. 2Get a personal plan
  3. 3Start learning
Book for β‚Ή200/ 30 min