Last active
October 27, 2015 00:52
-
-
Save dendisuhubdy/eb8e3c3ee3a32fdf6c51 to your computer and use it in GitHub Desktop.
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
# Definition for a binary tree node. | |
# class TreeNode(object): | |
# def __init__(self, x): | |
# self.val = x | |
# self.left = None | |
# self.right = None | |
class Solution(object): | |
def invertTree(self, root): | |
""" | |
:type root: TreeNode | |
:rtype: TreeNode | |
""" | |
if not root: | |
return None | |
else: | |
temp = self.invertTree(root.right) | |
root.right = self.invertTree(root.left) | |
root.left = temp | |
return root | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment