Insert Node at LCA and Re-parent Given Nodes

Asked at Aurora · Coding Questions · Difficulty: Medium · Last asked Jul 15, 2026

You are given a rooted tree as a list of `child parent` edges (the root is not marked separately: it is the one node whose parent is itself) and a group of target nodes. Find the Lowest Common Ancestor (LCA) of the targets, insert a new node directly below that LCA, and move every target so that it becomes a child of the new node.

Loading the problem…