4.1 leetcode -1 maximum-depth-of-binary-tree
2017-08-24 09:50
239 查看
题目: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.
这题比较简单,递归做即可
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 left = maxDepth(root->left); int right = maxDepth(root->right); if(left > right) return left + 1; else return right + 1; } } };
相关文章推荐
- [leetcode] 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:Minimum Depth of Binary Tree&& 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_104
- leetcode第一刷_Maximum Depth of Binary Tree
- LeetCode-Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree leetcode
- leetcode Maximum Depth of Binary Tree
- leetcode-104 Maximum Depth of Binary Tree
- 【LeetCode】【Python题解】Single Number & 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