LeetCode-Maximum Depth of Binary Tree
来源:互联网 发布:奥登大学数据 编辑:程序博客网 时间:2024/06/08 08:06
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.
Solution:Code:
<span style="font-size:14px;">/** * 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) { if (!root) return 0; int left = maxDepth(root->left); int right = maxDepth(root->right); return max(left, right)+1; }};</span>
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
- CentOS 6.4 卸载与安装桌面
- ArcGISViewer 中弹出框上的删除与缩小按钮如何去掉,记下来
- uva 11806 Cheerleaders
- 一个90后创业者血与泪的教训
- poj1236 Network of Schools ,有向图求强连通分量(Tarjan算法),缩点
- LeetCode-Maximum Depth of Binary Tree
- Vs2010编译错误集
- 面试题总结-最新
- C语言基础——关键字、标示符、注释
- 【代码优化】反射机制的慎用
- Linux 时间函数之 gettimeofday() 函数之使用方法
- 计算机基础--网络知识03
- alter
- C/C++:在编译的过程中动态指定宏