Problem 1666 · Medium

Change the Root of a Binary Tree

Walk from the leaf up its old parent chain, reversing each parent link and keeping every off-path child attached.

Open the interactive visualisation