LeetCode-Easy刷题(21) Maximum Depth of Binary Tree
2017-11-29 18:47
417 查看
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.
找出二叉树的最大深度.
public int maxDepth(TreeNode root) {
if(root ==null){
return 0;
}
return Math.max(maxDepth(root.left), maxDepth(root.right)) +1;
}
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
找出二叉树的最大深度.
public int maxDepth(TreeNode root) {
if(root ==null){
return 0;
}
return Math.max(maxDepth(root.left), maxDepth(root.right)) +1;
}
相关文章推荐
- [leetcode]21 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(104) Maximum Depth of Binary Tree
- leetcode:104 Maximum Depth of Binary Tree-每日编程第三题
- LeetCode:Minimum Depth of Binary Tree,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
- leetcode Maximum Depth of Binary Tree 非递归算法
- [leetcode]Maximum Depth of Binary Tree
- 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, 111]Maximum Depth of Binary Tree, Minimum Depth of Binary Tree
- 【Leetcode】【Easy】Maximum Depth of Binary Tree
- leetcode 刷题之路 62 Maximum Depth of Binary Tree
- LeetCode----Maximum Depth of Binary Tree