Problem · Array
Minimum Single-Rider Processing Speed
Learn this problemProblem statement
A rider must finish a sequence of order workloads within hours whole hours. At a positive integer speed k, an order with workload w takes ceil(w / k) hours.
- The rider works on only one order during an hour.
- Unused capacity in an order's final hour is lost.
Return the minimum positive integer speed that finishes every order within hours.
Function
minimumRiderSpeed(workloads: int[], hours: int) → intExamples
Example 1
workloads = [3,6,7,11]hours = 8return = 4At speed 4 the orders take 1, 2, 2, and 3 hours, totaling 8. Speed 3 requires 10 hours.
Example 2
workloads = [30,11,23,4,20]hours = 5return = 30There are five orders and five hours, so every order must finish in one hour.
Constraints
workloadsis non-empty and every workload is positive.hoursis at least the number of workloads.