Easy-题目3:104. Maximum Depth of Binary Tree

原创 2016年05月30日 19:44:58

题目原文:
Given a binary tree, find its maximum depth.
题目大意:
给出一个二叉树,求最大高度。
题目分析:
若节点为空,则返回0,否则返回左子树和右子树高度的最大值+1(根节点的高度)。依然一行代码解决。
源码:(language:java)

public class Solution {
    public int maxDepth(TreeNode root) {
        return (root==null)?0:Math.max(maxDepth(root.left),maxDepth(root.right))+1;
    }
}

成绩:
1ms,beats 9.54%,众数1ms,89.37%

版权声明:完整版Leetcode题解请出门左转https://github.com/cmershen1/leetcode/tree/master/docs

相关文章推荐

Leetcode 104. Maximum Depth of Binary Tree (Easy) (cpp)

Leetcode 104. Maximum Depth of Binary Tree (Easy) (cpp)

No104. Maximum Depth of Binary Tree

一、题目描述 Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along t...

Leetcode-104. Maximum Depth of Binary Tree c语言

来源:104. Maximum Depth of Binary Tree 题目要求: Given a binary tree, find its maximum depth. The max...

LeetCode104 Maximum Depth of Binary Tree

详细见:leetcode.com/problems/maximum-depth-of-binary-tree Java Solution: github package leetcod...

104/111 Maximum/Minimum Depth of Binary Tree(二叉树求深度)

104 Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the...

leetCode 104. Maximum Depth of Binary Tree

题目链接:https://leetcode.com/problems/maximum-depth-of-binary-tree/     题目内容: Given a binary tree, ...

LeetCode笔记:104.Maximum Depth of Binary Tree

计算二叉树的最大深度

104. Maximum Depth of Binary Tree

104. Maximum Depth of Binary Tree Given a binary tree, find its maximum depth. The maximum depth...

[LeetCode]104.Maximum Depth of Binary Tree

【题目】 Maximum Depth of Binary Tree  Total Accepted: 5260 Total Submissions: 11532My Submissions ...

LeetCode#104. Maximum Depth of Binary Tree

104. Maximum Depth of Binary Tree Given a binary tree, find its maximum depth. The maximum dep...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)