leetcode 226
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| /** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ struct TreeNode* invertTree(struct TreeNode* root) { struct TreeNode* temp; if(root == NULL) return NULL; else{ temp = root->left; root->left = invertTree(root->right); root->right = invertTree(temp); return root; } }
|
最后更新时间:
欢迎评论~