频道栏目
首页 > 资讯 > 其他 > 正文

编程算法Maximum Depth of Binary Tree

17-10-21        来源:[db:作者]  
收藏   我要投稿

编程算法Maximum Depth of Binary Tree,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.

solution:递归

code:

class Solution {
public:
    int maxDepth(TreeNode* root) {
    return root == NULL ? 0 : max(maxDepth(root -> left), maxDepth(root -> right)) + 1;
    }
};
相关TAG标签
上一篇:Java以面向对象编程为核心的编程范式群讲解
下一篇:C语言代码实现线性表、顺序表,及处理整型数据
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站