Skip to content

Commit 59f1192

Browse files
Solve : Invert Binary Tree
1 parent 3d686fd commit 59f1192

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Solution:
2+
def invertTree(self, root: Optional[TreeNode]) -> Optional[TreeNode]:
3+
if not root:
4+
return None
5+
root.left, root.right = root.right, root.left
6+
self.invertTree(root.left)
7+
self.invertTree(root.right)
8+
return root

0 commit comments

Comments
 (0)