标签:
struct TreeNode* invertTree(struct TreeNode* root) { if ( NULL == root ) { return NULL; } if ( NULL == root->left && NULL == root->right ) { //叶子节点 return root; } //交换左右子节点 struct TreeNode * pTreeNodeTmp = root->left; root->left = root->right; root->right = pTreeNodeTmp; invertTree(root->left); invertTree(root->right); return root; }
LeetCode —— Invert Binary Tree
标签:
原文地址:http://www.cnblogs.com/jabnih/p/4586797.html