Daily Temperatures

You are given an array temperatures, where temperatures[i] is the temperature on day i.

Return an array answer of the same length, where answer[i] is the number of days you have to wait after day i until a strictly warmer day. If no later day is warmer, answer[i] is 0.

Constraints

  • 1 <= temperatures.length <= 10^5
  • 30 <= temperatures[i] <= 100

Examples

Example 1

Input: temperatures = [71,69,72,76,70,73,75,68]
Output: [2,1,1,0,1,1,0,0]

Day 0 (71) waits 2 days for 72. No later day beats 76 (day 3), 75 (day 6) or 68 (day 7), so they get 0.

Example 2

Input: temperatures = [50,55,60]
Output: [1,1,0]

Each day is followed directly by a warmer one.

Example 3

Input: temperatures = [70,70,71]
Output: [2,1,0]

Equal is not warmer: day 0 has to wait until day 2.

JavaScript you'll use: Stacks, queues and deques Arrays: create, read, update

/**
 * @param {number[]} temperatures
 * @return {number[]}
 */
function dailyTemperatures(temperatures) {
  
}

Ctrl/⌘ + ' runs the examples, Ctrl/⌘ + Enter submits. Use console.log freely: output shows under Console. In the editor, press Esc then Tab to move focus out.