def depth(tree):
max_depth = 0
todo = [[tree,0]]
while len(todo) > 0:
node,depth = todo.pop(0)
if not node.left and not node.right:
if depth > max_depth:
max_depth = depth
if node.left:
todo.push([node.left,depth+1])
if node.right:
todo.push([node.right,depth+1])
Why is a manhole round?
Il y a 12 ans
Aucun commentaire:
Enregistrer un commentaire