Goldman Sachs Interview Question

You're given a 2d matrix. Apply bfs on it.