Trains the technique from
LeetCode 2101Detonate the Maximum BombsThis 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 quarry crew has laid shaped charges across a flat working floor. Each entry of bombs describes one charge with three whole numbers: bombs[i][0] and bombs[i][1] are the coordinates of the point where charge i is buried, and bombs[i][2] is how far its shock wave carries.
Firing a charge also fires every charge buried at a straight-line distance no greater than that reach, and each charge fired that way then sets off whatever its own shock wave covers, and so on until nothing new goes off. A burial point sitting exactly at the limit of the reach does go off. Reaches differ from charge to charge, so one charge covering another does not mean the favour is returned.
The crew fires exactly one charge by hand. Return the largest number of charges that can end up fired, counting the hand-fired one.
Example 1
Firing charge 0 by hand covers charge 1, whose burial point is 10 away and inside its range of 11. Charge 1 has a range of only 1 and covers nothing, so two charges fire in total.
Example 2
Firing charge 0 covers charge 1, which lies 4 away and within its range of 5. Charge 1 in turn covers charge 2, which is another 4 away and within its own range of 5. All three fire.
Example 3
The two burial points are 3 apart across and 4 apart up, so exactly 5 apart, and each charge has a range of 5. A point exactly on the rim counts, so firing either one fires both.
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 maximum_detonation(bombs: list[list[int]]) -> int:public int maximumDetonation(int[][] bombs)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.