Created
January 9, 2021 06:08
-
-
Save alecchendev/28c95d0b0ae1b4586087643a86412ec9 to your computer and use it in GitHub Desktop.
Invert Binary Tree Solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def invertTree(self, root: TreeNode) -> TreeNode: | |
if not root: | |
return None | |
left = root.left | |
right = root.right | |
root.left = self.invertTree(right) | |
root.right = self.invertTree(left) | |
return root |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment