← Google Interview Insights

Google·Software Engineer·Onsite - Coding / Algorithms·Intermediate

IntermediatePass
May 2026

Summary

Google SWE coding round, second in the loop. Got a variant of a classic graph/dynamic programming problem and it went well, probably the cleanest round I've had in a while.

Questions Asked (1)

Q1

Given a grid with bombs placed at various cells, find the maximum number of bombs you can detonate if each bomb triggers others within its blast radius (a variation on the classic chain detonation problem).

Algorithms & Data Structures
Author's notes

Had seen this one before, so the solution came fast.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the problem as a directed graph where each bomb is a node and edges represent detonation reachability. Then, find the maximum number of nodes reachable from any starting node, considering that detonations can propagate transitively. Use graph traversal algorithms like DFS/BFS or compute strongly connected components to handle cycles efficiently.

Pro tip: Clarify the blast radius definition (e.g., Manhattan distance vs. Euclidean) and whether bombs detonate simultaneously or sequentially, as this affects the graph construction and traversal. Also, discuss trade-offs between time and space complexity, and consider if the grid is sparse or dense.

1. Clarify problem constraints

Ask about blast radius metric, grid size, number of bombs, and whether detonation is simultaneous or sequential. Confirm if bombs can be detonated in any order and if the goal is to maximize total detonated bombs from a single initial detonation.

2. Model as a graph

Create a directed graph where each bomb is a node, and add a directed edge from bomb A to bomb B if B lies within A's blast radius. This captures the chain reaction potential.

3. Analyze graph properties

Identify strongly connected components (SCCs) to handle cycles where bombs detonate each other. Condense the graph into a DAG of SCCs, where each component's size is the number of bombs in it.

4. Compute maximum reachable bombs

For each SCC in the condensed DAG, compute the total number of bombs reachable from it (including itself) using dynamic programming or DFS with memoization. The maximum over all SCCs is the answer.

5. Optimize and discuss complexity

Analyze time and space complexity: building the graph takes O(n^2) in the worst case, SCC computation O(n+m), and DP O(n+m). Discuss potential optimizations like spatial indexing (e.g., k-d tree) for sparse grids.

Key Points to Mention

  • Graph representation: nodes as bombs, edges as detonation reachability.
  • Handling cycles with strongly connected components (SCCs) to avoid infinite loops.
  • Condensation of graph into DAG for efficient reachability computation.
  • Dynamic programming or DFS with memoization to count reachable bombs.
  • Time complexity: O(n^2) for graph construction, O(n+m) for SCC and DP.
  • Edge cases: isolated bombs, all bombs in one SCC, empty grid.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.