Problem

leetcode.com

Solution

This problem can be solve by DFS with depth of tree. In my code, lists.size() == depth means that the traversing depth changes.

Source Code