Dev
Mentor
Coach Interview AI
Mock Interview AI
Coding Problems
Blog
Pricing
Toggle theme
Sign In
Get Started
Toggle theme
Loading...
For the best coding experience, use a desktop browser.
Easy
Tree
Invert Binary Tree
Invert a binary tree (mirror it).
Examples
Input:
root = [4,2,7,1,3,6,9]
Output:
[4,7,2,9,6,3,1]
Sample Test Cases
Case 1 Input:
[4,2,7,1,3,6,9]
Expected:
[4,7,2,9,6,3,1]
Case 2 Input:
[2,1,3]
Expected:
[2,3,1]
Reset
Run
Submit
Loading editor...
Test Case
Output
Submission
Case 1 Input:
[4,2,7,1,3,6,9]
Expected:
[4,7,2,9,6,3,1]
Case 2 Input:
[2,1,3]
Expected:
[2,3,1]