Skip to content

Commit 66f9809

Browse files
committed
Invert Binary Tree Solution
1 parent 461ba12 commit 66f9809

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

invert-binary-tree/PDKhan.cpp

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

0 commit comments

Comments
 (0)