Maximum Depth of N-ary Tree LeetCode solution in Python

1
class Solution:
2
def maxDepth(self, root: "Node") -> int:
3

4
if not root:
5
return 0
6

7
if root.children:
8
return 1 + max([self.maxDepth(x) for x in root.children])
9
else:
10
return 1

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0