Java for LeetCode 104 Maximum Depth of Binary Tree
2024-08-26 13:26:24
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.
解题思路:
递归,JAVA实现如下:
public int maxDepth(TreeNode root) {
if(root==null)
return 0;
return Math.max(maxDepth(root.left), maxDepth(root.right))+1;
}
最新文章
- cookie详解
- linq 之 Distinct的使用
- Git教程学习(五)
- ASP.Net中无刷新执行Session身份验证
- Apache kafka原理与特性(0.8V)
- 2011 Asia Fuzhou Regional Contest
- 与MySQL交互(felixge/node-mysql)
- HTTP 缓存控制总结
- python小技巧
- 文件操作IO流
- 工程PMO工作
- Uncaught TypeError: Cannot read property &;#39;call&;#39; of undefined jquery.validate.min.js:28
- 51驱动LCD12864
- Linux下软件的卸载
- cmd 安装mysql
- 下载安装Android sdk tools
- MySQL数据库优化的方式
- Sqli-labs之sql注入基础知识
- Python全栈开发之7、模块和几种常见模块以及format知识补充
- She must be at least thirty-five years old.
热门文章
- Beginning Auto Layout Tutorial in iOS 7: Part 1
- SCP和SFTP相同点和区别
- DNS_主从服务_详细搭建&;&;配置
- 2016.7.12 eclipse和IDEA中mybatis generator插件的安装与使用
- 【剑指Offer面试题】 九度OJ1368:二叉树中和为某一值的路径
- GetDlgItem() 出现错误
- 分享个免费的货币汇率API
- Linux装mysqli.so
- C#各种导入Excel文件的数据的方法总结
- H5缓存机制学习记录