Daily OJ - 226. Flipping a Binary Tree
1.Topic: 226. Flip Binary Tree
2.Solution
2.1. Algorithm explanation
We start from the root node, recursively traverse the tree, and start flipping from the leaf nodes first. If the left and right subtrees of the currently traversed node
root
have been flipped, then we only need to exchange the positions of the two subtrees to complete takingroot
as the root Flip of the entire subtree of a node.