1516. Move Sub-Tree of N-Ary Tree
TreeDepth-First Search
Hints
Hint 1
Disconnect node p from its parent and append it to the children list of node q.
Hint 2
If q was in the sub-tree of node p (case 1), get the parent node of p and replace p in its children list with q.
Hint 3
If p was the root of the tree, make q the root of the tree.
Preparing judge…