您的位置:首页 > 其它

【LeetCode】Maximum Depth of Binary Tree 解题报告

2015-09-16 10:49 447 查看

Maximum Depth of Binary Tree

[LeetCode]

https://leetcode.com/problems/maximum-depth-of-binary-tree/

Total Accepted: 85334 Total Submissions: 188240 Difficulty: Easy

Question

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.

https://leetcode.com/problems/maximum-depth-of-binary-tree/

Examples



Ways

运用递归,递归左子树和右子树的深度,判断哪个子树的深度更大,计入总的树的深度。

Solution

托管在我的GitHub上:

https://github.com/fuxuemingzhu/DepthOfTree

Captures

测试结果截图:



Reference

算法之二叉树各种遍历

轻松搞定面试中的二叉树题目

Date

2015/9/16 10:42:06
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: