Given an array of integers temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer temperature.
Example 1
Input: temperatures = [73,74,75,71,69,72,76,73]
Output: [1,1,4,2,1,1,0,0]
Explanation: Day 0 (73) is followed by 74 the next day, so it waits 1. Day 2 (75) waits until day 6 (76), 4 days later. Day 3 (71) waits 2 days for 72. Days 6 and 7 never see a warmer day, so they get 0.
Example 2
Input: temperatures = [30,40,50,60]
Output: [1,1,1,0]
Explanation: Each day is warmer than the one before, so every day waits exactly 1 day, except the last, which gets 0.
Example 3
Input: temperatures = [30,60,90]
Output: [1,1,0]
Explanation: The temperatures rise every day, so the first two days each wait 1 day and the last day gets 0.
Each day `j` can "resolve" the wait time for earlier colder days. Keep a stack of unresolved day-indices in decreasing temperature order. A warmer day pops everyone it dominates.
Run checks all cases above. Submit evaluates all test cases.