Skip to content

Instantly share code, notes, and snippets.

@zhy0216
Created March 4, 2017 05:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhy0216/c8163b1312bec2185fb55bbbd2df548b to your computer and use it in GitHub Desktop.
Save zhy0216/c8163b1312bec2185fb55bbbd2df548b to your computer and use it in GitHub Desktop.
class Solution(object):
def invertTree(self, root):
"""
:type root: TreeNode
:rtype: TreeNode
"""
if root is None:
return root
if root.left:
self.invertTree(root.left)
if root.right:
self.invertTree(root.right)
root.left, root.right = root.right, root.left
return root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment