Leetcode #104 Maximum Depth of Binary Tree
来源:互联网 发布:nb仿真实验室软件 编辑:程序博客网 时间:2024/06/06 02:33
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.
Difficulty:Easy
class Solution {public: int dep = 1; void reco(TreeNode* root,int curr){ if(root==NULL) { dep = dep>curr?dep:curr; return; } reco(root->left,curr+1); reco(root->right,curr+1); } int maxDepth(TreeNode* root) { if(root==NULL) return 0; reco(root->left,1); reco(root->right,1); return dep; }};
0 0
- 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
- 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
- 通过代码自定义cell(cell的高度不一致)
- eclipseMars4.5+maven3+jetty8的简单使用
- HDU 4365 正方形格子涂色中心对称轴对称的涂法有多少种-思维-(矩阵坐标关系&快速幂取模)
- 关于NSArray的一些用法
- 使用CXF开发web service 的客户端 (四)
- Leetcode #104 Maximum Depth of Binary Tree
- 动画解释
- nginx 清理日志
- 基于bootstrap的网页开发(导航条和下拉菜单)
- 关于fragment与activity的思考,以及出现的问题
- a[href*=javablackbelt]{color:red};
- [ASM]Linux平台内联汇编实例
- 线上事故处理总结
- Linux 截图