Created
December 23, 2015 10:25
-
-
Save lyleaf/bc75b359a061e21a9601 to your computer and use it in GitHub Desktop.
Python Algorithms
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 | |
root.left, root.right = root.right, root.left | |
map(self.invertTree, (root.left,root.right)) | |
return root |
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
Change value use tuple. | |
Use map. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment