Meta Interview Question

leetcode problem on DFS BFS