Skip to content
    SeaCode
    Learning tracksCode ArenaWorkshops & EventsInstructors
    Log inSign up
    Practice problems / Slowest eating speed that works

    Slowest eating speed that works

    Mediumbinary searcharray

    There are banana piles piles and h hours. Each hour you pick a pile and eat k bananas from it (finishing a smaller pile and waiting out the hour). Return the smallest k that finishes everything within h hours.

    Example 1

    Input:  piles = [3,6,7,11], h = 8
    Output: 4

    Example 2

    Input:  piles = [30,11,23,4,20], h = 5
    Output: 30

    Constraints

    • 1 ≤ piles.length ≤ 10⁴
    • piles.length ≤ h ≤ 10⁹
    • 1 ≤ piles[i] ≤ 10⁹

    Submit checks your solution against 9 tests, including hidden ones.

    /**
     * @param {int[]} piles
     * @param {int} h
     * @return {int}
     */
    function minEatingSpeed(piles, h) {
      
    }
    
    Sign in to run
    SeaCode

    Learn to code for real, online or at our branch in front of Cairo University, Giza.

    Learn

    • All courses
    • Interactive tutorials
    • Interview practice problems
    • Mock interview
    • Learning tracks
    • Code Arena
    • Workshops & Events
    • Knowledge library
    • Team projects

    Your account

    • Log in
    • Sign up
    • Learning plan
    • Certificates
    • Site map

    Contact us

    • WhatsApp
    • 010 9094 1104
    • In front of Cairo University, Giza

    © 2026 SeaCode. All rights reserved.