leetcode 226 Invert Binary Tree
leetcode 226 Invert Binary Tree
递归方法
/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ struct TreeNode* invertTree(struct TreeNode* root) { if(root==NULL) return root; struct TreeNode* temp = invertTree(root->left); root->left = invertTree(root->right); root->right = temp; }