Pergunta de entrevista da empresa Databricks

A grid question about finding the shortest route (in time) using DFS or BFS