leetcode559 Python3 128ms N叉树的最大深度

"""
# Definition for a Node.
class Node(object):
    def __init__(self, val, children):
        self.val = val
        self.children = children
"""
class Solution(object):
    def maxDepth(self, root):
        """
        :type root: Node
        :rtype: int
        """
        if not root:
            return 0
        if not root.children:
            return 1
        return 1 + max(list(map(self.maxDepth, root.children)))
        
posted @ 2018-07-28 00:36  一条图图犬  阅读(550)  评论(0编辑  收藏  举报