Skip to content

Commit ee55e7d

Browse files
committed
solve in 3 minutes
1 parent 561cc31 commit ee55e7d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Definition for a binary tree node.
2+
# class TreeNode:
3+
# def __init__(self, val=0, left=None, right=None):
4+
# self.val = val
5+
# self.left = left
6+
# self.right = right
7+
class Solution:
8+
def maxDepth(self, root) -> int:
9+
if not root:
10+
return 0
11+
if root.left == None and root.right == None:
12+
return 1
13+
return max(self.maxDepth(root.left), self.maxDepth(root.right)) + 1

0 commit comments

Comments
 (0)