Meta interview question

leetcode problem on DFS BFS