luoheng
10/6/2019 - 1:46 PM

maxDepth

"""
# Definition for a Node.
class Node:
    def __init__(self, val, children):
        self.val = val
        self.children = children
"""
class Solution:
    def maxDepth(self, root: 'Node') -> int:
        if root is None:
            return 0
        elif not root.children:
            return 1
        else:
            return 1 + max(self.maxDepth(node) for node in root.children)