Meta interview question

Two dimensional BFS floodfill problem