Kraken interview question

coding: BFS over a matrix