This is 0ms solution

```
TreeNode* invertTree(TreeNode* root) {
if (root) {
TreeNode *right = root->right, *left= root->left;
root->right = invertTree(left);
root->left = invertTree(right);
}
return root;
}
```

This Is 3ms solution

```
TreeNode* invertTree(TreeNode* root) {
if (root != NULL)
{
TreeNode* temp = root->left;
root->left=root->right;
root->right=temp;
invertTree(root->left);
invertTree(root->right);
}
return root;
}
```