"""
# Definition for a Node.
class Node:
def __init__(self, val=None, children=None):
self.val = val
self.children = children
"""
class Solution:
def maxDepth(self, root: 'Node') -> int:
if not root:
return 0
else:
max_value = 0
for child in root.children:
temp = self.maxDepth(child)
if temp > max_value:
max_value = temp
return max_value +1
leetcode 559 N叉树的最大深度
最新推荐文章于 2024-05-20 18:16:07 发布