FastPrepDays Until a Warmer Day
Problems/Days Until a Warmer Day

Days Until a Warmer Day

C3.ai logoC3.ai● MediumNEW GRADPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Two C3.ai new grad reports list this problem. A 2022 report from a Forward Deployed Engineer tech screen says the question was the classic daily temperatures problem with a small twist. A 2021 report from the onsite for a data software role says one round used a problem much like it.

Neither report says what the twist was. This version is the plain task: each day gets the number of days until a strictly warmer day, an equal temperature does not count, and the answer is 0 when no warmer day comes. The limits are our choice.

Our version is about 75% the same as the reported questions.

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

For each day, find how many days you have to wait after it until a day that is strictly warmer. Return an array answer of the same length, where answer[i] is that number of days.

  • A later day with the same temperature does not count as warmer.
  • If no later day is warmer than day i, then answer[i] is 0.

Function

daysUntilWarmer(temperatures: int[]) → int[]

Examples

Example 1

temperatures = [3,5,4,4,7,2]return = [1,3,2,1,0,0]

Day 0 (3) is followed by 5 on day 1, so it waits 1 day. Day 1 (5) waits until 7 on day 4, which is 3 days. Day 2 (4) also waits for day 4, 2 days later: day 3 has the same temperature 4, which is not warmer. Day 3 waits 1 day. No later day is warmer than day 4 (7) or day 5 (2), so both get 0.

Example 2

temperatures = [10,10,10]return = [0,0,0]

Every day has the same temperature. A day with an equal temperature is not warmer, so every answer is 0.

Example 3

temperatures = [-5,-8,-2,0]return = [2,1,1,0]

Temperatures can be below zero. Day 0 (-5) and day 1 (-8) both wait for -2 on day 2, which is 2 days and 1 day away. Day 2 waits 1 day for 0. The last day gets 0.

Constraints

  • 1 <= temperatures.length <= 2000
  • -100 <= temperatures[i] <= 100

More C3.ai interview questions

  • Fewest Turns to Open a Wheel LockPHONE SCREEN · Seen Nov 2024
  • Longest Run of Ones After Flipping k ZerosPHONE SCREEN · Seen Mar 2022
  • Top K Frequent ElementsPHONE SCREEN · Seen Feb 2021
  • Item Prices From Material CostsPHONE SCREEN · Seen Dec 2020
  • Adjacent-Key Lock PatternsPHONE SCREEN · Seen Feb 2014
  • Drop Recent Duplicate MessagesOA · Seen Oct 2026
  • Maximum K-Star SumOA · Seen Oct 2026
  • Every Result of Grouping an ExpressionONSITE INTERVIEW · Seen Jan 2023
  • Fewest Jumps to the Last IndexONSITE INTERVIEW · Seen Jan 2023
  • Rotate a Square Grid ClockwiseONSITE INTERVIEW · Seen Jan 2023

Similar questions at other companies

  • Asteroid CollisionSiemens · PHONE SCREEN
  • Billing Log with Undo and RedoReddit · PHONE SCREENReddit interview questions
  • Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Daily TemperaturesCARS24 · PHONE SCREEN
  • Flatten a Mixed JSON ListNike, Inc. · ONSITE INTERVIEWNike, Inc. interview questions
  • Next Greater Indices and Maximum GapTikTok · PHONE SCREENTikTok interview questions
  • Fountain SafetyGoogle · ONSITE INTERVIEWGoogle interview questions
  • Trace Events from Stable Whole-Stack StatesAnthropic · ONSITE INTERVIEWAnthropic interview questions
  • Next Smaller Ticket PriceAmazon · ONSITE INTERVIEW
  • Next Greater Value in a Circular ArrayPayPay · PHONE SCREENPayPay interview questions

Interview reports that mention this question

  • C3.ai FDE and Other New Grad Roles: 5 Experiences (Part 2 of 2)

C3.ai interview experiences

  • C3.ai New Grad Interviews: 25 Experiences (Part 1 of 2)
  • C3.ai New Grad Forward Deployed Engineer Interview: 1 Experience
All C3.ai interview questionsSee C3.ai hiring insights
Saved
class Solution {
    public int[] daysUntilWarmer(int[] temperatures) {
        // Write your code here.
    }
}
Checking account…