Skip to content

Commit 232c292

Browse files
authored
Create 226. Invert Binary Tree 18 feb (#96)
226. Invert Binary Tree
2 parents e4178be + c258e26 commit 232c292

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

226. Invert Binary Tree 18 feb

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution {
2+
public:
3+
TreeNode* invertTree(TreeNode* root) {
4+
5+
if(root == NULL) return root;
6+
swap(root->left, root->right);
7+
invertTree(root->left);
8+
invertTree(root->right);
9+
10+
return root;
11+
}
12+
};

0 commit comments

Comments
 (0)