Count Days until a Strictly Warmer Reading

Quick Overview

Count Days until a Strictly Warmer Reading. For each day, return how many days pass before the first later temperature strictly greater than that day's reading.

Count Days until a Strictly Warmer Reading

Company: Google

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Other

### Problem For each day, return how many days pass before the first later temperature strictly greater than that day's reading. Return zero when there is no warmer future day. ```cpp class Solution { public: vector<int> dailyTemperatures(vector<int>& temperatures); }; ``` ### Examples **Example 1:** ```text temperatures = [70,70,72,71] Output: [2,1,0,0] Explanation: Equal readings do not resolve either of the first two days. ``` **Example 2:** ```text temperatures = [90,80] Output: [0,0] Explanation: Neither day has a warmer later reading. ``` ### Constraints - There are 1 through 100000 daily readings. - Each reading is between 30 and 100 inclusive. ### Contract considerations Return one wait count per original day. ```hint Read the boundary condition Which unresolved days can the current temperature settle? ``` ### Boundary reminders Return one wait count per original day.

Overview: Count Days until a Strictly Warmer Reading. For each day, return how many days pass before the first later temperature strictly greater than that day's reading.

Google logo
Google
Source window: 0–3 months · as of Oct 21, 2026
mediumSoftware EngineerOtherCoding & Algorithms
0
0

Problem

For each day, return how many days pass before the first later temperature strictly greater than that day's reading. Return zero when there is no warmer future day.

class Solution {
public:
    vector<int> dailyTemperatures(vector<int>& temperatures);
};

Examples

Example 1:

temperatures = [70,70,72,71]
Output: [2,1,0,0]
Explanation: Equal readings do not resolve either of the first two days.

Example 2:

temperatures = [90,80]
Output: [0,0]
Explanation: Neither day has a warmer later reading.

Constraints

  • There are 1 through 100000 daily readings.
  • Each reading is between 30 and 100 inclusive.

Contract considerations

Return one wait count per original day.

Boundary reminders

Return one wait count per original day.