Skip to content

Commit 759d65c

Browse files
committed
code did not save before push
1 parent 059846c commit 759d65c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

invert-binary-tree/Solution.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Definition for a binary tree node.
3+
* public class TreeNode {
4+
* int val;
5+
* TreeNode left;
6+
* TreeNode right;
7+
* TreeNode(int x) { val = x; }
8+
* }
9+
*/
10+
public class Solution {
11+
public TreeNode invertTree(TreeNode root) {
12+
if(root == null) return null;
13+
14+
TreeNode newLeft = invertTree(root.right);
15+
TreeNode newRight = invertTree(root.left);
16+
17+
root.left = newLeft;
18+
root.right = newRight;
19+
20+
return root;
21+
}
22+
}

0 commit comments

Comments
 (0)