Altitude AI interview question

A leetcode medium BFS/DFS problem