Skip to content

Commit 81ea16d

Browse files
Max_Depth_of_Binary_Tree
1 parent da7e14c commit 81ea16d

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

100_Same Tree

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Definition for a binary tree node.
2+
# class TreeNode:
3+
# def __init__(self, x):
4+
# self.val = x
5+
# self.left = None
6+
# self.right = None
7+
8+
class Solution:
9+
def maxDepth(self, root):
10+
"""
11+
:type root: TreeNode
12+
:rtype: int
13+
"""
14+
if None == root:
15+
return 0
16+
depth_left = self.maxDepth(root.left)
17+
depth_right = self.maxDepth(root.right)
18+
return(max(depth_left + 1, depth_right + 1))

0 commit comments

Comments
 (0)