Pregunta de entrevista de Applied Intuition

Question was a graph traversal problem on a grid