function getHeight(tree) {
if(tree === null) return 0
let left = getHeight(tree.left)+1
let right = getHeight(tree.right)+1
return left > right ? left : right
}
function getHeight(tree) {
if(tree === null) return 0
let left = getHeight(tree.left)+1
let right = getHeight(tree.right)+1
return left > right ? left : right
}
本文标题:获取树的最大高度
本文链接:https://www.haomeiwen.com/subject/bpvrwhtx.html
网友评论