Leetcode---(104)Maximum Depth of Binary Tree
来源:互联网 发布:linux安装amd显卡驱动 编辑:程序博客网 时间:2024/05/22 06:07
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.
首先考虑递归
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Solution {public: int maxDepth(TreeNode* root) { if(root==NULL) return 0; return max(maxDepth(root->left),maxDepth(root->right))+1; }};
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
- [转]初学者JavaScript 小技巧总结
- 黑马程序员-----------网络编程
- struts自定义转化器
- 2015061706 - 工作反思
- Struts2工具类
- Leetcode---(104)Maximum Depth of Binary Tree
- 百度地图坐标转换服务封装(优化批量并发异步访问)
- OpenGL学习之路--StartPoint
- sql中exists、not exists的用法
- 【java基础】——IO流(上)
- Java版DBHelper【简单】(MySQL数据库)
- ApartmentState
- Linux常用命令积累
- Leetcode 之 Remove Duplicates from Sorted Array II