Dashboard
LC #739
Daily Temperatures
Pattern · ?AmazonGoogleMetaBloomberg
Problem
Given daily temperatures, return an array where answer[i] is the number of days until a warmer day.
Constraints
- 1 ≤ n ≤ 10⁵
- 30 ≤ temperatures[i] ≤ 100
Example
- Input
- temperatures = [73, 74, 75, 71, 69, 72, 76, 73]
- Output
- [1, 1, 4, 2, 1, 1, 0, 0]
- Why
- Day 0 (73°): wait 1 day for 74°. Day 2 (75°): wait 4 days for 76°
Spot the pattern
Which pattern cracks it?
Hints
One at a time