获取树的最大高度
2020-07-12 本文已影响0人
Time_Notes
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
}