Skip to content

Instantly share code, notes, and snippets.

@dendisuhubdy
Created October 27, 2015 00:53
Show Gist options
  • Save dendisuhubdy/51060b46d81d5effe2a8 to your computer and use it in GitHub Desktop.
Save dendisuhubdy/51060b46d81d5effe2a8 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 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