ByteDance Interview Question

A DFS coding problem and a recursion coding problem.