Skip to content

Commit fc65849

Browse files
committed
Add invert binary tree Solution
1 parent acdd81f commit fc65849

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

invert-binary-tree/s0ooo0k.java

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

0 commit comments

Comments
 (0)