diff --git a/lc104. Maximum Depth of Binary Tree.py b/lc104. Maximum Depth of Binary Tree.py new file mode 100644 index 0000000..fc40816 --- /dev/null +++ b/lc104. Maximum Depth of Binary Tree.py @@ -0,0 +1,18 @@ +# Definition for a binary tree node. +# class TreeNode: +# def __init__(self, x): +# self.val = x +# self.left = None +# self.right = None + + +class Solution: + def maxDepth(self, root): + """ + :type root: TreeNode + :rtype: int + """ + if not root: + return 0 + else: + return 1 + max(self.maxDepth(root.left), self.maxDepth(root.right))