Invert Binary Tree Problem
Invert Binary Tree Problem — ExecCode Medium DSA Practice
Solve the Invert Binary Tree problem on ExecCode. Free online medium DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Given the root of a binary tree, invert the tree, and return its root. Inverting means swapping every left child with its right child recursively.
Examples
Input root = [4, 2, 7, 1, 3, 6, 9]; Output [4, 7, 2, 9, 6, 3, 1]. Input root = [2, 1, 3]; Output [2, 3, 1]
Constraints
Range of nodes: [0, 100] -100 <= Node.val <= 100
Practice Invert Binary Tree free on ExecCode. Browse DSA problems, topic map, and placement guides.