Skip to content

Commit fdc0c0a

Browse files
committed
[week2] solve 226. Invert Binary Tree
1 parent 7e22b46 commit fdc0c0a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

invert-binary-tree/bky373.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* - 문제: https://leetcode.com/problems/linked-list-cycle/
3+
* - TC: O(N)
4+
* - SC: O(N)
5+
*/
6+
public class Solution_226 {
7+
public TreeNode invertTree(TreeNode root) {
8+
if (root == null) {
9+
return null;
10+
}
11+
TreeNode tmp = root.left;
12+
root.left = invertTree(root.right);
13+
root.right = invertTree(tmp);
14+
return root;
15+
}
16+
}

0 commit comments

Comments
 (0)