[leetcode]Maximum Depth of Binary Tree
来源:互联网 发布:slackware 网络配置 编辑:程序博客网 时间:2024/06/03 21:07
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.
解题思路 : 后续遍历二叉树的应用
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Solution {public: int maxDepth(TreeNode *root) { // Note: The Solution object is instantiated only once and is reused by each test case. if(root == NULL) return 0; int lh = maxDepth(root->left); int rh = maxDepth(root->right); int h; h = lh > rh ? lh + 1 : rh + 1; return h; }};
0 0
- Leetcode - Tree - Maximum Depth of Binary Tree
- [leetcode][tree] Maximum Depth of Binary Tree
- LeetCode Maximum Depth of Binary Tree
- [Leetcode] Maximum Depth of Binary Tree
- leetcode 24: Maximum Depth of Binary Tree
- [LeetCode] Maximum Depth of Binary Tree
- Leetcode 104 Maximum Depth of Binary Tree
- 【leetcode】Maximum Depth of Binary Tree
- [leetcode]Maximum Depth of Binary Tree
- [LeetCode]Maximum Depth of Binary Tree
- [leetcode]Maximum Depth of Binary Tree
- Leetcode: Maximum Depth of Binary Tree
- LeetCode-Maximum Depth of Binary Tree
- [leetcode] Maximum Depth of Binary Tree
- LeetCode - Maximum Depth of Binary Tree
- LeetCode:Maximum Depth of Binary Tree
- LeetCode | Maximum Depth of Binary Tree
- 【leetcode】Maximum Depth of Binary Tree
- hadoop的一些常见问题及解决方法
- 八皇后问题(EightQueens)
- 第7天 软考踩点灾难日
- 终端运行hadoop
- 我是否该走编程这条路?
- [leetcode]Maximum Depth of Binary Tree
- spring监听器初始化任务
- Cocos2d-x中在Android里切换竖屏
- 第8天 决定放弃妹子,专心考研,继续努力!
- Tomcat内存溢出
- VC++的Unicode编程
- 在linux环境下搭建hadoop平台(伪分布式)
- 记录信管历程
- 使用rman duplicate创建物理active standby dataguard