leetle

Daily challenge for 2026-07-10

556. Optimal Drone Delivery Speed

A fleet of delivery drones needs to transport packages to a remote island. Each drone can carry one package per trip. You are given an array of integers distances, where each element represents the distance to a package's destination in kilometers, and an integer max_time representing the maximum total hours allowed to complete all deliveries.

Each drone travels at a constant integer speed of $s$ km/h. The time taken to deliver a package of distance $d$ at speed $s$ is rounded up to the nearest integer hour, i.e., $\lceil d / s \rceil$ hours. Find the minimum integer speed $s$ (where $s \ge 1$) such that all packages can be delivered within max_time hours.

Example:
Input: distances = [3, 6, 7, 11], max_time = 8
Output: 4
Explanation: At speed 4, the delivery times are [1, 2, 2, 3] hours, totaling 8 hours. At speed 3, the times are [1, 2, 3, 4] hours, totaling 10 hours, which exceeds the limit.

Run this challenge interactively in Python or JavaScript when the app loads.