LinkedIn interview question

DFS/BFS, 2D matrix