标签:solution roo node int treenode 二叉树 null val rtt
1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x), left(NULL), right(NULL) {} 8 * }; 9 */ 10 class Solution 11 { 12 public: 13 TreeNode* invertTree(TreeNode* root) 14 { 15 if(root == NULL) return NULL; 16 TreeNode* a = invertTree(root->left); 17 TreeNode* b = invertTree(root->right); 18 root->left = b; 19 root->right = a; 20 return root; 21 } 22 };
标签:solution roo node int treenode 二叉树 null val rtt
原文地址:https://www.cnblogs.com/yuhong1103/p/12681812.html