Skip to content

Commit 0541a61

Browse files
committed
Time: 31 ms (96.84%) | Memory: 17.7 MB (68.34%) - LeetSync
1 parent 964483d commit 0541a61

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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: Optional[TreeNode]) -> int:
9+
if not root:
10+
return 0
11+
12+
return 1 + max(self.maxDepth(root.left),self.maxDepth(root.right))
13+
14+
15+

0 commit comments

Comments
 (0)