Amazon Interview Question

BFS on a 2 dimensional grid.