lc.226 翻转二叉树
![[Pasted image 20241124154400.png | 300]] |
1
2
3
4
5
6
7
TreeNode* invertTree(TreeNode* root) {
if (root == NULL) return root;
swap(root->left, root->right); // 中
invertTree(root->left); // 左
invertTree(root->right); // 右
return root;
}
![[f276aedd3a1dabf10d664030cb22583.png | 300]] |
This post is licensed under CC BY 4.0 by the author.