Data Structures19 sections · 729 units
Open in Course

Problem - Daily Temperatures

Next greater with indices

Given an array of daily temperatures, return an array where each element says how many days until a warmer temperature. If there is no future warmer day, put 00.

Example: [73,74,75,71,69,72,76,73][73, 74, 75, 71, 69, 72, 76, 73] Answer: [1,1,4,2,1,1,0,0][1, 1, 4, 2, 1, 1, 0, 0] You're solving "next greater element" but you return distances instead of values. You'll need to store indices on the stack, not values.