I went with Manhattan distance first and the interviewer was fine with that, just wanted me to document the choice.
First, clarify the problem constraints and define the blast radius helper. Then, model the search state to include which bombs have been detonated, and adapt BFS/DFS to explore states with different wall configurations. Discuss trade-offs between state space explosion and optimality, and propose optimizations like memoization or A* with admissible heuristics.
Pro tip: Emphasize that the state must include the set of detonated bombs (or equivalently, the current wall configuration) to avoid incorrect paths; a common pitfall is to treat bombs as one-time triggers without tracking their effect on the grid.
Ask about blast radius metric (Chebyshev vs Manhattan), whether bombs can be detonated multiple times, and if the traveler can choose to detonate or must detonate upon stepping. Confirm if the goal is to find the shortest path in terms of steps.
Write a function that, given a bomb position and radius, returns all wall cells within the blast radius that become passable. Consider using a set to avoid duplicates and handle boundaries.
Extend the state to include the set of detonated bombs (or a bitmask if bombs are few). The state is (position, detonated_bombs). This ensures the search correctly reasons about different wall configurations.
Modify the search to explore transitions: moving to adjacent cells (if passable) and detonating a bomb (if stepping on it). Update the wall configuration upon detonation. Use a visited set for states to avoid cycles.
Discuss the exponential blow-up in states (2^B * N*M). Propose optimizations: only track bombs that affect the path, use A* with a heuristic, or precompute blast effects. Mention trade-offs between optimality and efficiency.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.