Meta·Software Engineer·Technical Phone Screen
- Given a 2D grid with a start cell and a destination cell, find a path from start to destination while avoiding walls. How do you approach this, and when would you choose BFS over DFS?
“I started with BFS because shortest path, but then fumbled a bit explaining why BFS guarantees it on an unweighted grid while DFS doesn't.”