Databricks Interview Question

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