Problem · Graph
Detonate Bombs with Chain Reactions
Learn this problemProblem statement
You are given n bombs. Each bomb is represented as [x, y, r], where (x, y) is its location and r is its explosion radius.
If bomb i is detonated, it directly triggers every bomb j whose Euclidean distance from bomb i is at most r_i. A triggered bomb can then trigger other bombs, creating a chain reaction.
You may choose exactly one bomb as the initial detonation. Return the maximum number of bombs that can be detonated.
Function
maximumDetonatedBombs(bombs: int[][]) → intExamples
Example 1
bombs = [[2,1,3],[6,1,4],[4,1,1]]return = 3Detonating the second bomb triggers both other bombs directly, so all three bombs detonate.
Example 2
bombs = [[0,0,1],[3,0,1]]return = 1Example 3
bombs = [[0,0,10],[3,0,1],[6,0,1]]return = 3Constraints
1 <= bombs.length <= 100bombs[i].length == 3-10^5 <= x_i, y_i <= 10^51 <= r_i <= 10^5- Use 64-bit squared distances to avoid overflow and floating-point precision issues.
More Google problems
- Deduplicate Logs: Keep FirstONSITE INTERVIEW · Seen Jul 2026
- Deduplicate Logs: Keep LatestONSITE INTERVIEW · Seen Jul 2026
- Find a Template Across Binary-Tree LeavesONSITE INTERVIEW · Seen Jul 2026
- Maximum Programmer-Problem MatchingONSITE INTERVIEW · Seen Jul 2026
- Minimum Direction ViolationsONSITE INTERVIEW · Seen Jul 2026
- Stream Latest Log VersionsONSITE INTERVIEW · Seen Jul 2026
- Stream Unique Logs in Timestamp OrderONSITE INTERVIEW · Seen Jul 2026
- Top-K IP Addresses from File RecordsONSITE INTERVIEW · Seen Jul 2026