标签:href com color tco script rip http return def
测试代码
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 public: 12 TreeNode* invertTree(TreeNode* root) 13 { 14 if(!root) 15 return nullptr; 16 dfs(root->left, root->right); 17 return root; 18 } 19 20 void dfs(TreeNode* &p, TreeNode* &q) 21 { 22 if(!p && !q) 23 return; 24 std::swap(p, q); 25 if(p) 26 dfs(p->left, p->right); 27 if(q) 28 dfs(q->left, q->right); 29 } 30 };
标签:href com color tco script rip http return def
原文地址:https://www.cnblogs.com/sunbines/p/9676564.html