CodeMentor
.
Ask AI
Problems
Learn
C++
TCS
Core CS
HR
Progress
Search
Ctrl
K
0
Lv 1
Problems
Binary Trees
Invert Binary Tree
Easy
LeetCode
1/3
00:00
Hint
Run
Ctrl
↵
Submit
Description
Lesson
Code walk
Solution
Easy
Binary Trees
LeetCode #226
Invert Binary Tree
Swap left/right recursively (or BFS).
Examples
Example 1
Input
4 2 7 1 3 6 9
Output
4 7 2 9 6 3 1
Stuck? Take a nudge
Reveal hint 1 of 3
C++17
Autosaves
Reset
Console
Run your code to see results