LeetCode 226. Invert Binary Tree
Given the root of a binary tree, invert the tree, and return its root.
Example:
method: 递归
翻转每个节点的左右节点
TreeNode* invertTree(TreeNode* root) {
if (root == nullptr) return root;
swap(root->left, root->right);
invertTree(root->left); // 递归处理左右子树
invertTree(root->right);
return root;
}