Maximum Depth of Binary Tree
生活随笔
收集整理的這篇文章主要介紹了
Maximum Depth of Binary Tree
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
Given a binary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
Subscribe?to see which companies asked this question
給定一個二叉樹,找出其最大深度。?
二叉樹的深度為根節(jié)點(diǎn)到最遠(yuǎn)葉子節(jié)點(diǎn)的距離。
如果二叉樹為空,則深度為0?
如果不為空,分別求左子樹的深度和右子樹的深度,去最大的再加1,因?yàn)楦?jié)點(diǎn)深度是1,要加進(jìn)去。
總結(jié)
以上是生活随笔為你收集整理的Maximum Depth of Binary Tree的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。