Skip to content

Commit 5634819

Browse files
authored
Create e559.py
1 parent 1a85301 commit 5634819

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

my-submissions/e559.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
# Definition for a Node.
3+
class Node:
4+
def __init__(self, val: Optional[int] = None, children: Optional[List['Node']] = None):
5+
self.val = val
6+
self.children = children
7+
"""
8+
9+
class Solution:
10+
def maxDepth(self, root: 'Node') -> int:
11+
if not root :
12+
return 0
13+
if not root.children :
14+
return 1
15+
return max(self.maxDepth(x) for x in root.children) + 1

0 commit comments

Comments
 (0)