题解 | #二叉树的最大深度#
二叉树的最大深度
https://www.nowcoder.com/practice/8a2b2bf6c19b4f23a9bdb9b233eefa73?tpId=295&tags=&title=&difficulty=0&judgeStatus=0&rp=0&sourceUrl=%2Fexam%2Foj%3Fpage%3D1%26tab%3D%25E7%25AE%2597%25E6%25B3%2595%25E7%25AF%2587%26topicId%3D295%26fromPut%3Dpc_kol_aaaxiu
function maxLength (root){
if(!root) return 0
else if(!root.left&&!root.right) return 1
else return Math.max(maxLength(root.left),maxLength(root.right))+1
}
利用递归,和js的内置函数max来判断二叉树的深度