Created
November 11, 2010 06:16
-
-
Save zhaoz/672103 to your computer and use it in GitHub Desktop.
closures in python
This file contains hidden or 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
def getHeight(self, node=None): | |
maxHeight = [0] | |
def traverse(node, height): | |
if not node: | |
return | |
height += 1 | |
if height > maxHeight[0]: | |
maxHeight[0] = height | |
traverse(node.left, height) | |
traverse(node.right, height) | |
if not node: | |
node = self.root | |
traverse(node, 0) | |
return maxHeight[0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment