All questions
EasyTrees · Recursion
Invert Binary Tree
Written by a community member · · 1 attempt · 0% pass
0
Given the root of a binary tree, invert the tree and return its root. Inverting a binary tree means swapping the left and right children of every node in the tree. The transformation may be performed in place.
The number of nodes is between 0 and 100, and each node value is between -100 and 100.
Examples:
- Input tree
[4,2,7,1,3,6,9]becomes[4,7,2,9,6,3,1]. - Input tree
[2,1,3]becomes[2,3,1]. - An empty tree
[]remains[].
Return None when the input tree is empty.