1、题目

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.

Subscribe to see which companies asked this question.

2、代码实现

/*** Definition for a binary tree node.* public class TreeNode {*     int val;*     TreeNode left;*     TreeNode right;*     TreeNode(int x) { val = x; }* }*/
public class Solution {public int maxDepth(TreeNode root) {if (root == null) return 0;return  1 + Math.max(maxDepth(root.left), maxDepth(root.right));}
}

LeetCode之Maximum Depth of Binary Tree相关推荐

  1. Leetcode | Minimum/Maximum Depth of Binary Tree

    Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum depth is the n ...

  2. 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 l ...

  3. 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 ...

  4. [swift] 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:Minimum Depth of Binary Tree,Maximum Depth of Binary Tree

    LeetCode:Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum depth ...

  6. 【LeetCode 剑指offer刷题】树题4:104 Maximum Depth of Binary Tree

    [LeetCode & 剑指offer 刷题笔记]目录(持续更新中...) 104. Maximum Depth of Binary Tree Given a binary tree, fin ...

  7. LeetCode——Maximum Depth of Binary Tree

    LeetCode--Maximum Depth of Binary Tree Question Given a binary tree, find its maximum depth. The max ...

  8. 【LeetCode】104. Maximum Depth of Binary Tree (2 solutions)

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

  9. LeetCode 104. Maximum Depth of Binary Tree--二叉树高度--递归或迭代--C++,Python解法

    题目地址:Maximum Depth of Binary Tree - LeetCode Given a binary tree, find its maximum depth. The maximu ...

最新文章

  1. 用OpenGL进行曲线、曲面的绘制
  2. smartdns使用指南_Windows10 玩SmartDNS告别污染
  3. Zookeeper集群搭建(配置详解)
  4. python 判断每月最后一天_python获取某年中每个月的第一天和最后一天的两种方法...
  5. intention lock_写作技巧:你写出来的情节有用吗?好情节的原则——LOCK系统
  6. IDEA2018部署jeesite3完美运行教程
  7. CUDA计算向量内积的程序(源自CUDA范例编程)
  8. 同步异步-阻塞非阻塞
  9. pip常用命令、配置pip源
  10. Nordic Blue Tooth
  11. Java jsp 自定义标签
  12. __declspec(dllimport)和__declspec(dllexport)的区别,以及有关c/c++调用约定
  13. 建立保持时间及违例解决方法
  14. excel 第5讲:分类汇总与数据有效性
  15. win7显示器双屏显示怎么设置
  16. 从零到一写一个完整的 Compose 版本的天气
  17. pythonista去掉图片背景色是哪条语句?
  18. Pycharm安装.ignore
  19. 微信新彩蛋太 6 了,满屏爱心合为一心,还可以炸屎...
  20. Java MVC模式和三层架构

热门文章

  1. 测试龙芯 LoongArch .NET之 使用 FastTunnel 做内网穿透远程计算机
  2. FastTunnel - 打造人人都能搭建的内网穿透工具
  3. 【视频回放】Best of Build Tour in China 暨 Watching Party - 大湾区专场
  4. .NET 6 Preview 1 开箱,带你体验新版本
  5. 谷歌微软高通反对英伟达收购ARM 值得国人深思
  6. 网传不要升级.NET5的诸多原因,你赞同几个?
  7. 【Blog.Core重要升级】:封装服务扩展层
  8. 数据结构与算法专题——第四题 字符串相似度
  9. 在 Visual Studio 2019 中为 .NET Core WinForm App 启用窗体设计器
  10. 解析“60k”大佬的19道C#面试题(下)