ASAPUtils Logo ASAPUtils
Week 3

Daily Temperatures

Daily Temperatures as the clean next-greater-element template, with the decreasing stack invariant, an O(n) amortised proof, C++ and JavaScript solutions, and a day-by-day visualizer.

The problem

For every day's temperature, return how many days must pass until a warmer temperature occurs. Return zero for a day that never gets a warmer future temperature.

temperatures = [73,74,75,71,69,72,76,73] -> [1,1,4,2,1,1,0,0]

Related Problems