题目描述:

解题思路:

代码:

public int MaxDepth(TreeNode root)
{
if (root == null) return 0;
return Mathf.Max(MaxDepth(root.left) + 1, MaxDepth(root.right) + 1);
}

来源:http://www.1994july.club/

Leetcode(104)之二叉树的最大深度的更多相关文章

  1. Leetcode(104)-二叉树的最大深度

    给定一个二叉树,找出其最大深度. 二叉树的深度为根节点到最远叶子节点的最长路径上的节点数. 说明: 叶子节点是指没有子节点的节点. 示例:给定二叉树 [3,9,20,null,null,15,7], ...

  2. [Leetcode 104]求二叉树的深度Depth of BinaryTree

    [题目] Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the ...

  3. 递归的三部解题曲 关联leetcode 104. 二叉树最大深度练习

    递归关心的三点 1. 递归的终止条件 2. 一级递归需要做什么 3. 返回给上一级递归的返回值是什么 递归三部曲 1. 找到递归的终止条件:递归什么时候结束 2. 本级递归做什么:在这级递归中应当完成 ...

  4. [LeetCode] 104. Maximum Depth of Binary Tree 二叉树的最大深度

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

  5. LeetCode 104. 二叉树的最大深度(Maximum Depth of Binary Tree)

    104. 二叉树的最大深度 104. Maximum Depth of Binary Tree 题目描述 给定一个二叉树,找出其最大深度. 二叉树的深度为根节点到最远叶子节点的最长路径上的节点数. 说 ...

  6. 【Leetcode】104. 二叉树的最大深度

    题目 给定一个二叉树,找出其最大深度. 二叉树的深度为根节点到最远叶子节点的最长路径上的节点数. 说明: 叶子节点是指没有子节点的节点. 示例:给定二叉树 [3,9,20,null,null,15,7 ...

  7. Java实现 LeetCode 104 二叉树的最大深度

    104. 二叉树的最大深度 给定一个二叉树,找出其最大深度. 二叉树的深度为根节点到最远叶子节点的最长路径上的节点数. 说明: 叶子节点是指没有子节点的节点. 示例: 给定二叉树 [3,9,20,nu ...

  8. Leetcode 104. Maximum Depth of Binary Tree(二叉树的最大深度)

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

  9. LeetCode(104):二叉树的最大深度

    Easy! 题目描述: 给定一个二叉树,找出其最大深度. 二叉树的深度为根节点到最远叶子节点的最长路径上的节点数. 说明: 叶子节点是指没有子节点的节点. 示例:给定二叉树 [3,9,20,null, ...

随机推荐

  1. 第一个flink application

    导入maven依赖 需要注意的是,如果使用scala写程序,导入的依赖跟java是不一样的 Maven Dependencies You can add the following dependenc ...

  2. 吴裕雄--天生自然C++语言学习笔记:C++ 文件和流

    如何从文件读取流和向文件写入流.这就需要用到 C++ 中另一个标准库 fstream,它定义了三个新的数据类型: ofstream 该数据类型表示输出文件流,用于创建文件并向文件写入信息. ifstr ...

  3. java 实体 set数据 报空指针异常

    今天在做一个调用阿里云AXB隐私保护,需要调用通话记录的消费队列,然后set到实体中,然后插入到数据库,但是set的这一步报错 以为工具拿不到值,然后打印发现是有值的, 然后再看一下实例的类型是没错的 ...

  4. springboot - 映射HTTP Response Status Codes 到 静态 HTML页面

    1.总览 2.代码 1).pom.xml <dependencies> <dependency> <groupId>org.springframework.boot ...

  5. 覆盖.project

    <?xml version="1.0" encoding="UTF-8"?> <projectDescription> <name ...

  6. BZOJ:1927: [Sdoi2010]星际竞速

    题解:最小费用流+二分图模型: 左边表示出这个点,右边表示入这个点: #include<iostream> #include<cstdio> #include<cstri ...

  7. 自学Java第五章——《面向对象基础》

    5.1 类与对象 1.类:一类具有相同特性的事物的抽象描述. 对象:类的一个个体,实例,具体的存在. 类是对象的设计模板. 2.如何声明类? [修饰符] class 类名{    成员列表:属性.方法 ...

  8. linux_c_udp_example

    udp_server #include <stdlib.h> #include <string.h> #include <unistd.h> #include &l ...

  9. matplotlib画图--Line Color

    1.线形 2.标记 3.颜色

  10. POJ 1011:Sticks 经典搜索

    Sticks Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 128734   Accepted: 30173 Descrip ...