LeetCode 104: Maximum Depth of Binary Tree 题解
来源:互联网 发布:车辆轨迹 大数据分析 编辑:程序博客网 时间:2024/06/05 06:35
这道题非常简单:
LeetCode 104: 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.
通过代码:
// Cint maxDepth(struct TreeNode* root) { if(!root) return 0; int l = maxDepth(root->left); int r = maxDepth(root->right); return 1 + (l > r ? l : r);}// C++int maxDepth(struct TreeNode* root) { if(!root) return 0; return max(maxDepth(root->left), maxDepth(root->right)) + 1;}
0 0
- LeetCode题解:Maximum Depth of Binary Tree
- LeetCode题解:Maximum Depth of Binary Tree
- LeetCode题解:Maximum Depth of Binary Tree
- LeetCode题解-104-Maximum Depth of Binary Tree
- LeetCode 104: Maximum Depth of Binary Tree 题解
- LeetCode 104 Maximum Depth of Binary Tree题解
- Leetcode 104 Maximum Depth of Binary Tree
- LeetCode(104)Maximum Depth of Binary Tree
- LeetCode 104 Maximum Depth of Binary Tree
- LeetCode: Maximum Depth of Binary Tree [104]
- Leetcode(104)Maximum Depth of Binary Tree
- [leetcode 104] Maximum Depth of Binary Tree
- LeetCode 104 Maximum Depth of Binary Tree
- leetCode #104 Maximum Depth of Binary Tree
- LeetCode 104: Maximum Depth of Binary Tree
- LeetCode 104 Maximum Depth of Binary Tree
- leetcode || 104、Maximum Depth of Binary Tree
- LeetCode 104: Maximum Depth of Binary Tree
- POJ1018(DP)
- SSH密钥登录让VPS下centos服务器更安全
- 单例模式的常见应用场景
- 设计模式:访问者模式(Vistor)
- Android 自定义Toast:轻松实现深度可定制化的Toast
- LeetCode 104: Maximum Depth of Binary Tree 题解
- Eclipse 安装svn插件
- 设计模式:各个模式间的对比
- NOIP 提高组 飞扬的小鸟
- 不root手机解决INSATALL_FAILD_UID
- HTML5入门大二下暑假总结---2
- 计算机网路-网络层
- java中的原子操作类AtomicInteger及其实现原理
- uva 524Prime Ring Problem