DoorDash | Phone Screen | Fulfill orders
Anonymous User
1687

You're given an array of pending orders at restaurants. A dasher must complete all orders in given hours h. You must use all hours. Return the minimum speed at which the dasher must fulfill the orders. Return -1 if not possible.

Examples:

orders = [4, 3, 1]. So index 0 has 4 orders, index 1 has 3 orders and index 3 has 1 order
hours = 4
result speed would be 3 orders per hour
You would need to spend 2 hours at the first restaurant to fulfill 4 orders, 1hr at second restaurant and so on. You cannot use "left over" capacity from restaurants.

orders = [2,2,2]
hours = 3
result speed in this case would be 2 orders per hour

orders = [100, 2, 2]
hours = 4
result speed would be 50 orders per hour

orders = [100, 100]
hours = 3
result would be -1

Comments (7)