You are managing operations at a large Amazon warehouse. Loaded trucks arrive at the warehouse sequentially and must be unloaded within a specific timeframe to ensure timely delivery. Your task is to determine the minimum number of dock bays needed to unload all trucks within the given timeframe.
Formally, given a scheduling array truckCargoSize of length n, where each unit in the array represents the amount of time in minutes that a dock bay will take to unload the cargo from the ith truck, and a second integer, maxTurnaroundTime, representing the total allowed time to unload trucks, find the smallest number of dock bays d that will enable you to unload all trucks within maxTurnaroundTime minutes.
Notes:
Complete the function getMinimumDockBays in the editor.
getMinimumDockBays has the following parameters:
int truckCargoSize[n]: the time in minutes for the dock bay to unload cargo from theith trucklong maxTurnaroundTime: the maximum allowed total unloading time.
Returns
int: the smallest number of dock bays d to unload all the cargo within maxTurnaroundTime minutes.
💙 Many thanks to the incredible friend who shared this source!
truckCargoSize = [3, 4, 3, 2, 3] maxTurnaroundTime = 8 return = 3

truckCargoSize = [2, 3, 1] maxTurnaroundTime = 7 return = 1
1 ≤ n ≤ 5 * 10^41 ≤ maxTurnaroundTime ≤ 10^15 (looks like 15 to me..)1 ≤ truckCargoSize[i] ≤ min (maxTurnaroundTime 10^9)
- Count Promotional PeriodsOA · Seen Jun 2026
- Find Maximum Total Amount (SDE I, Fungible :)Seen Jun 2026
- Get Minimum AmountOA · Seen Jun 2026
- Find Minimum CostOA · Seen Jun 2026
- Get Smallest Base SegmentOA · Seen Jun 2026
- Select Least Resource TasksOA · Seen Jun 2026
- Product Category Group SizesPHONE SCREEN · Seen May 2026
- Count Connected ComponentsPHONE SCREEN · Seen May 2026
public int getMinimumDockBays(int[] truckCargoSize, long maxTurnaroundTime) {
// write your code here
}