Skip to content

Commit 9ff1a42

Browse files
Merge pull request #2046 from CodingTestStudy2/염혜정
[염혜정] Day18
2 parents 50c31e1 + eea6d87 commit 9ff1a42

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)