Back to DSA

Invert Binary Tree

easy
Acceptance: 68%
Binary Tree

Given the root of a binary tree, produce its mirror image by swapping the left and right children at every node throughout the tree. Return the root of the transformed tree.

Examples

Example 1:
Input:root = [1,2,3,4,5,6,7]
Output:[1,3,2,7,6,5,4]
Example 2:
Input:root = [8,6,10]
Output:[8,10,6]

Hints

00:00
1234567