Problem 1516 · Medium

Move Sub-Tree of N-Ary Tree

Lift node p and its subtree under q; when q sits inside that subtree, first move q into p’s old slot so no node is lost.

Open the interactive visualisation