Meta interview question

1 bfs, 1 dfs question from leetcode