1666. Change the Root of a Binary Tree
TreeDepth-First SearchBinary Tree
Hints
Hint 1
Start traversing from the leaf. Always go up till you reach the root.
Hint 2
Change pointers as asked, make the current node's parent its left child, and make the left child the right one if needed.
Preparing judge…