Skip to content

Commit 7b79914

Browse files
Create 226-Invert-Binary-Tree.java
1 parent 6229f42 commit 7b79914

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

java/226-Invert-Binary-Tree.java

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

0 commit comments

Comments
 (0)