Invert Binary Tree LeetCode solution in C++

1
class Solution {
2
public:
3
TreeNode *invertTree(TreeNode *root) {
4
if (root == NULL) return root;
5
TreeNode *temp = root->left;
6
root->left = root->right;
7
root->right = temp;
8
invertTree(root->left);
9
invertTree(root->right);
10
return root;
11
}
12
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0