LC 104. Maximum Depth of Binary Tree
1.题意
104. Maximum Depth of Binary Tree
Easy
98540
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.
Note: A leaf is a node with no children.
Example:
Given binary tree [3,9,20,null,null,15,7]
,
3/ \9 20/ \15 7
return its depth = 3.
2.代码
class Solution {
public:int maxDepth(TreeNode* root) {if(root==NULL) {return 0;}else return max(1 + maxDepth(root -> left), 1 + maxDepth(root -> right));}
};
LC 104. Maximum Depth of Binary Tree相关推荐
- 【LeetCode 剑指offer刷题】树题4:104 Maximum Depth of Binary Tree
[LeetCode & 剑指offer 刷题笔记]目录(持续更新中...) 104. Maximum Depth of Binary Tree Given a binary tree, fin ...
- 【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 ...
- 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 ...
- Leet Code OJ 104. Maximum Depth of Binary Tree [Difficulty: Easy]
题目: 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
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...
- 【leetcode】104. Maximum Depth of Binary Tree
1. 题目 Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along th ...
- leetcode python3 简单题104. Maximum Depth of Binary Tree
1.编辑器 我使用的是win10+vscode+leetcode+python3 环境配置参见我的博客: 链接 2.第一百零四题 (1)题目 英文: Given a binary tree, find ...
- [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 ...
- 104. Maximum Depth of Binary Tree (Easy)
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...
最新文章
- 分布式服务框架 dubbo/dubbox 入门示例(转)
- LVS负载均衡群集部署之——DR模式的介绍及搭建步骤
- 极光推送 android 最新,Android——快速集成极光推送-Go语言中文社区
- Web.py session用户认证
- 1047: 对数表 ZZULIOJ
- STM32 SPI驱动OLED12864原理图和源代码分享
- [转]struct和class的区别 观察者模式 https连接 点击button收到点
- Windows编程语言VBA学习(四)——VBA代码调试
- jojo第七部dio怎么复活_JOJO杂谈:DIO复活的那些年到底在干什么?
- 在centos上更改服务器时区(美国时间、北京时间)
- 谨慎选择我们的先验 - 对最优拟合概率分布搜索空间的一种约束
- java马里奥_java马里奥毕业设计
- 【机器学习】基于生成对抗网络的黑白图片上色
- java nio 学习笔记2
- 思科模拟器入门基础-静态路由
- Ubuntu防火墙UFW
- 解决maven库中没有Oracle jdbc驱动的问题Cannot resolve com.oracle:ojdbc14:10.2.0.1.0
- 1.操作系统——内核
- 错误代码 0x80070035 找不到网络路径 终极解决办法
- 未明学院:有趣or有用,九款人工智能小程序/APP推荐给你
热门文章
- 关于电影的HTML网页设计-威海影视网站首页-电影主题HTM5网页设计作业成品
- inet_addr报错
- 4K高清壁纸应用Pap.er Mac中文版
- 【优化】梯度下降 收敛性 证明
- java 实现登录超时,Java-实现异地登陆和超时登陆
- 使用uber数据集和kelpergl做路网动态可视化
- [源码和文档分享]基于C++的餐厅管理程序的设计与实现
- 2019最新计算机毕业设计-题目汇总大全-系列4
- Azkaban (一) --------- Azkaban 概论
- 1000元计算机配置方案,1000元赛扬J345低功耗主机推荐 2018最便宜电脑配置方案 (全文)...