Invert a binary tree.
4 / 2 7 / / 1 3 6 9
to
4 / 7 2 / / 9 6 3 1
1 TreeNode* invertTree(TreeNode* root) { 2 if(root==NULL) 3 return NULL; 4 TreeNode* temp; 5 temp=root->right; 6 root->right=invertTree(root->left); 7 root->left=invertTree(temp); 8 return root; 9 }