Given the root of a binary tree, flip the tree upside down and return the new root.
You can turn a binary tree upside down by applying the following steps:
The original left child becomes the new root.
The original root becomes the new right child.
The original right child becomes the new left child.
The transformation is applied from the bottom of the tree up to the original root.
Constraints:
The number of nodes in the tree is in the range
Node.val
Every right node in the tree has a sibling (a left node that shares the same parent).
Every right node in the tree has no children.
Given the root of a binary tree, flip the tree upside down and return the new root.
You can turn a binary tree upside down by applying the following steps:
The original left child becomes the new root.
The original root becomes the new right child.
The original right child becomes the new left child.
The transformation is applied from the bottom of the tree up to the original root.
Constraints:
The number of nodes in the tree is in the range
Node.val
Every right node in the tree has a sibling (a left node that shares the same parent).
Every right node in the tree has no children.