Created
October 27, 2015 00:53
-
-
Save dendisuhubdy/51060b46d81d5effe2a8 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 maxDepth(self, root): | |
if not root: | |
return 0 | |
else: | |
return max(self.maxDepth(root.left), self.max(root.right)) + 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment