[Daily OJ——226. Flip Binary Tree]

1.Topic: 226. Flip Binary Tree

Insert image description here

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 taking root as the root Flip of the entire subtree of a node.

2.2. Code implementation

Insert image description here

2.3. Code submission passes display

Insert image description here

Guess you like

Origin blog.csdn.net/qq_73900397/article/details/134757379