Skip to content

Commit df3fc89

Browse files
committed
226. Invert Binary Tree
1 parent 886209b commit df3fc89

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

invert-binary-tree.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//Runtime: 0 ms
2+
class Solution {
3+
public:
4+
TreeNode* invertTree(TreeNode* root) {
5+
if(!root)
6+
return root;
7+
8+
swap(root->left, root->right);
9+
invertTree(root->left);
10+
invertTree(root->right);
11+
return root;
12+
}
13+
};

0 commit comments

Comments
 (0)