CodeMentor.
Ask AIProblemsLearnC++TCSCore CSHRProgress
0Lv 1
ProblemsBinary Trees

Invert Binary Tree

Easy
LeetCode
1/3
EasyBinary TreesLeetCode #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

C++17Autosaves