二叉树的最小深度
想不出来啊
遍历的单层逻辑
我还以为要在上面ifnot下功夫
结果还要判断root的左右节点的区别
if root.left and not root.right:
return 1 + l_h
if root.right and not root.left:
return 1 + r_h
想不出来啊
遍历的单层逻辑
我还以为要在上面ifnot下功夫
结果还要判断root的左右节点的区别
if root.left and not root.right:
return 1 + l_h
if root.right and not root.left:
return 1 + r_h