[Leetcode] Maximum Depth of Binary Tree (Java)
2014-01-20 12:41
369 查看
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.
计算二叉树高度
public class Solution { public int maxDepth(TreeNode root) { if(root==null) return 0; return 1+Math.max(maxDepth(root.left), maxDepth(root.right)); } }
相关文章推荐
- Maximum Depth of Binary Tree leetcode java
- (java)leetcode Maximum Depth of Binary Tree
- leetcode:Maximum Depth of Binary Tree 【Java】
- 【LeetCode-面试算法经典-Java实现】【104-Maximum Depth of Binary Tree(二叉树的最大深度)】
- [Leetcode][JAVA] Minimum Depth of Binary Tree && Balanced Binary Tree && Maximum Depth of Binary Tree
- [LeetCode-104]Maximum Depth of Binary Tree (java)
- [LeetCode][Java] Maximum Depth of Binary Tree
- LeetCode 104 -Maximum Depth of Binary Tree ( JAVA )
- LeetCode之Maximum Depth of Binary Tree(Java版)
- LeetCode 104 Maximum Depth of Binary Tree JAVA
- [Java代码] [Leetcode] Maximum and Minimum Depth of Binary Tree 二叉树的最小最大深度
- [LeetCode][Java]Maximum Depth of Binary Tree
- Java [Leetcode 104]Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree | leetcode 104 【Java解题报告】
- Java for LeetCode 104 Maximum Depth of Binary Tree
- 【LeetCode-面试算法经典-Java实现】【104-Maximum Depth of Binary Tree(二叉树的最大深度)】
- LeetCode|Maximum Depth of Binary Tree-java
- [leetcode] Maximum Depth of Binary Tree
- 【leetcode刷题笔记】Maximum Depth of Binary Tree
- Leetcode-Maximum Depth of Binary Tree