Eliminate Maximum Number of Monsters
A medium-tier problem at 51% community acceptance, tagged with Array, Greedy, Sorting. Reported in interviews at Agoda and 0 others.
You're facing monsters at varying distances, each moving toward you at different speeds. The catch: you can only eliminate one per turn, and if any monster reaches you, the game ends. This greedy sorting problem tests whether you can identify the right elimination order before time runs out. Agoda has asked it. The acceptance rate sits just above 50%, which means half the candidates who attempt it either miss the greedy insight or implement it wrong. If you blank on the ordering logic during your live assessment, StealthCoder surfaces a working solution invisible to the proctor.
Companies that ask "Eliminate Maximum Number of Monsters"
Eliminate Maximum Number of Monsters is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made for the engineer who has done the work but might still blank with a webcam pointed at him.
Get StealthCoderThe trap is thinking you should target the closest monster or the fastest one. The actual trick: sort by the time each monster takes to reach you, then eliminate in that order. A monster with distance D and speed S will arrive in D/S time units. If you can eliminate monsters faster than they arrive, you win. The greedy choice is to always pick the monster with the shortest arrival time next. Most candidates either skip the math (forgetting to calculate actual arrival time) or implement a naive sort that doesn't account for both distance and speed together. During the assessment, if you can't derive the formula under pressure, StealthCoder handles the sorting logic and boundary checks instantly, letting you move past the problem without a time penalty.
Pattern tags
You know the problem.
Make sure you actually pass it.
Eliminate Maximum Number of Monsters recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made for the engineer who has done the work but might still blank with a webcam pointed at him. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Eliminate Maximum Number of Monsters interview FAQ
Why is this greedy and not dynamic programming?+
Each turn you eliminate one monster. Greedy works because you want to prevent any single monster from reaching you. Always picking the one arriving soonest guarantees the longest survival window. DP would be overkill and slower. Greedy is provably optimal here.
What's the actual ordering formula?+
Sort monsters by arrival time: distance / speed. Eliminate in ascending order of arrival time. If you can eliminate all monsters before any arrives, you win. If one arrives before you eliminate it, you lose. The math is simple but easy to forget under pressure.
Is this still asked at Agoda and similar companies?+
Agoda has confirmed it. At 50% acceptance, it's a standard medium-difficulty screen used to filter candidates who understand greedy algorithms and can handle floating-point comparisons without panicking.
What are the common implementation pitfalls?+
Forgetting to calculate arrival time as distance / speed, not handling the case where you eliminate all monsters on time, and integer division errors if using the wrong data type. Also easy to sort in the wrong direction or compare arrival times before computing them.
How does this relate to the Array and Sorting topics?+
You iterate through an array of monsters and sort them by a calculated property (arrival time). The Array and Sorting topics confirm the solution involves preprocessing the input list, then walking through it in a specific order to make greedy decisions.
Want the actual problem statement? View "Eliminate Maximum Number of Monsters" on LeetCode →