Trains the technique from
LeetCode 1921Eliminate Maximum Number of MonstersThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A fence is guarded by a single cannon. There are n drones approaching it. Drone i starts dist[i] metres away and closes on the fence at speed[i] metres per minute, so it reaches the fence after dist[i] / speed[i] minutes.
The cannon fires the moment the alarm sounds, at minute 0, and downs one drone instantly. It then needs one whole minute to reload, so it can fire again at minute 1, minute 2, and so on. A drone that reaches the fence at exactly the minute the cannon becomes ready cannot be shot: the breach happens first.
Return the number of drones the cannon downs before a drone reaches the fence.
Example 1
The drones arrive after 0.6, about 0.67 and 2 minutes. The shot at minute 0 downs one of them, and by minute 1 the other of that pair has already reached the fence.
Example 2
The drones arrive at minutes 3, 5, 7 and 9. The cannon is ready at minutes 0, 1, 2 and 3, and every one of those is before the matching arrival.
Example 3
All three drones reach the fence at minute 1, so only the shot at minute 0 lands.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def drones_downed(dist: list[int], speed: list[int]) -> int:public int dronesDowned(int[] dist, int[] speed)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.