FastPrepMinimum Eating Speed
Problems/Minimum Eating Speed

Minimum Eating Speed

Airbnb logoAirbnb● MediumFULLTIMEINTERNOA

Updated Nov 2026

QuestionFunctionExamples

Problem statement

Source note: The source provides the complete Halloween Candy statement, sample, and core constraints. The judged core task matches the visible source at about 99%.

Your daughter, Alex, has just come home with a bag full of candy after a long night of trick-or-treating. Before going to sleep, Alex places the candy in numPiles piles with the i-th pile containing candyPiles[i] number of candies.

After arranging the candies into piles, Alex announces she is going to sleep for numHours hours.

Your plan is to eat all the candy before Alex wakes up in numHours. You can eat c candies per hour, but in each hour you will only eat candy from a single pile. If a pile contains fewer than c candies, you will only eat the number of candies in that pile and you will wait until the next hour to eat more candy.

Having a little bit of self-restraint your goal is to calculate the smallest number of candies c you need to eat per hour in order to finish all the candy before Alex wakes up again.

Function

minimumEatingSpeed(candyPiles: int[], numHours: int) → int

Complete the function minimumEatingSpeed in the editor.

minimumEatingSpeed has the following parameters:

  1. int[] candyPiles: an array of integers representing the number of candies in each pile
  2. int numHours: the number of hours Alex will be asleep for

Returns int: the smallest number of candies c that you need to eat per hour in order to finish all the candies before Alex wakes up

Examples

Example 1

candyPiles = [4, 9, 11, 17]numHours = 8return = 6

To finish all the candies in 8 hours, you can eat at the following speed:

  • Hour 1: Eat 6 candies from the pile with 17 candies, 11 remain.
  • Hour 2: Eat 6 candies from the pile with 11 candies, 5 remain.
  • Hour 3: Eat 5 candies from the pile with 5 candies, 0 remain.
  • Hour 4: Eat 6 candies from the pile with 9 candies, 3 remain.
  • Hour 5: Eat 3 candies from the pile with 3 candies, 0 remain.
  • Hour 6: Eat 4 candies from the pile with 4 candies, 0 remain.
  • Hour 7: Eat 6 candies from the pile with 11 candies, 5 remain.
  • Hour 8: Eat 5 candies from the pile with 5 candies, 0 remain.

The smallest number of candies you need to eat per hour is 6.

More Airbnb interview questions

  • Bouncing DiagonalsOA · Seen Dec 2026
  • Count Numbers Not Equal to the First TwoOA · Seen Dec 2026
  • Garden Sprinkler PlacementOA · Seen Dec 2026
  • Theme Park Shuttle Wait TimeOA · Seen Dec 2026
  • Merge Event PreferencesPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Run-Length Encoding and DecodingPHONE SCREEN · Seen Nov 2026
  • Count Card Duel RoundsOA · Seen Nov 2026
  • Count Lamps Lighting Each PointOA · Seen Nov 2026
  • Simulate Orchard Rot SpreadOA · Seen Nov 2026
  • Sort Adjacent PairsOA · Seen Nov 2026

Similar questions at other companies

  • Minimum Non-Adjacent Selection CapabilityMicrosoft · OAMicrosoft interview questions
  • Count Pairs of Overlapping SquaresCapital One · OACapital One interview questions
  • Bank Accounts with Balance HistoryMeta · OAMeta interview questions
  • Index of the Maximum After Left RotationsChubb · OAChubb interview questions
  • Rolling MetricsAkuna Capital · OAAkuna Capital interview questions
  • Longest Increasing Price SubsequenceOpenAI · OAOpenAI interview questions
  • Linear InterpolatorTwo Sigma · OATwo Sigma interview questions
  • Rock JumpingIMC Trading · OAIMC Trading interview questions
  • Find Sum of BeautiesAmazon · OA
  • Minimum Cost to Attend Required CoursesVisa · OAVisa interview questions

Interview reports that mention this question

  • Airbnb Intern OA, Halloween Candy: 22 Experiences (Part 3 of 7)
  • Airbnb SWE Intern OA / Interviews: 122 Experiences (Part 1 of 7)

Airbnb interview experiences

  • Airbnb OA · November 2026
  • Airbnb Campus and Full-Time SWE OA / Interviews: 9 Experiences
  • Airbnb Intern Phone Interviews: 21 Experiences (Part 7 of 7)
  • Airbnb Intern OA and Phone Screens: 17 Experiences (Part 6 of 7)
All Airbnb interview questionsSee Airbnb hiring insights
Saved
class Solution {
    public int minimumEatingSpeed(int[] candyPiles, int numHours) {
        // write your code here
    }

}
Checking account…