Skip to content

Instantly share code, notes, and snippets.

@dendisuhubdy
Last active October 27, 2015 00:52
Show Gist options
  • Save dendisuhubdy/eb8e3c3ee3a32fdf6c51 to your computer and use it in GitHub Desktop.
Save dendisuhubdy/eb8e3c3ee3a32fdf6c51 to your computer and use it in GitHub Desktop.
# 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