ThoughtExchange interview question

Grid manipulation and graph traversal