Global Relay interview question

DFS coding challenge and Backtracking pattern.