LeetCode(104)Maximum Depth of Binary Tree
来源:互联网 发布:网络剧版权价值 编辑:程序博客网 时间:2024/05/22 04:52
题目如下:
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.
题目分析:
简单题。求树的最大深度。递归求解。
class Solution {public: int maxDepth(TreeNode *root) { if(root==NULL) return 0; else{ int l=maxDepth(root->left); int r=maxDepth(root->right); return 1+(l>r?l:r); } }};
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
- 说一说 framebuffer,从前,现在.......
- webapi 返回数据类型控制(json,xml)
- [leet code] Swap Nodes in Pairs
- 初识SVN
- LeetCode(100)Same Tree
- LeetCode(104)Maximum Depth of Binary Tree
- 内联函数与宏定义
- jquery中美元符号命名冲突的解决办法
- 查看Linux是32位还是64位的方法
- jquery 输入框动态增减的代码
- [leet code] Pascal's Triangle
- Android学习小demo(3)自定义ViewGroup 利用 scroller 实行屏幕滚动
- Gucci erwarb die Schweizer Gesellschaft Fabbrica Quadranti Wahl Woolrich 2013 Sale Polar Parka Herre
- 相由心生 运由意转