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 longest path from the root node down to the farthest leaf node.
求二叉树的最大深度
/*** 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;}int left = maxDepth(root.left);int right = maxDepth(root.right);return Math.max(left, right) + 1;} }
转载于:https://www.cnblogs.com/iwangzheng/p/5768592.html
leetcode 104. Maximum Depth of Binary Tree相关推荐
- 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 ...
- [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 ...
- 【LeetCode 剑指offer刷题】树题4:104 Maximum Depth of Binary Tree
[LeetCode & 剑指offer 刷题笔记]目录(持续更新中...) 104. Maximum Depth of Binary Tree Given a binary tree, fin ...
- 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 m ...
- 【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--二叉树高度--递归或迭代--C++,Python解法
题目地址:Maximum Depth of Binary Tree - LeetCode Given a binary tree, find its maximum depth. The maximu ...
- 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 ...
- leetcode python3 简单题104. Maximum Depth of Binary Tree
1.编辑器 我使用的是win10+vscode+leetcode+python3 环境配置参见我的博客: 链接 2.第一百零四题 (1)题目 英文: Given a binary tree, find ...
- 【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 ...
最新文章
- 你真的了解软件测试行业吗?
- mysql mydumper_采用mydumper对MySQL部分数据库进行热备
- 面向对象和面向过程,python中的类class,python中程序的入口——main方法,
- java条件触发_java – 当给定75:android时,条件不会触发
- 深圳华为 C++面试题
- 栅栏密码怎么写java程序_[CTF]栅栏密码学习
- Android Studio开发引入Speex
- 海淘也疯狂 跨境电商网站8月监测报告
- 手机通信专有名词中英文
- 微信小程序云函数数组删除和添加并排序操作pull,push 用法
- SQP 序列二次规划法
- php开发之Composer包
- php获得opcode,php opcode 缓存
- python系列tkinter之pack布局、place布局和grid布局
- 2022年欧莱雅-联合国教科文组织 “世界杰出女科学家成就奖”获奖人名单公布...
- 打开excel,提示 flash play2 错误,解决办法
- java 羽化_JAVA10来了 - 羽化布凉的个人空间 - OSCHINA - 中文开源技术交流社区
- java 摩尔斯电码_Java实现 LeetCode 804 唯一摩尔斯密码词 (暴力)
- Linux知识点总结
- (导航页)OpenStack-M版-双节点手工搭建-附B站视频
热门文章
- 02如何抓住重点,系统高效地学习数据结构与算法?
- Lucene学习总结之三:Lucene的索引文件格式(2)
- C# System.Windows.Forms.NumericUpDown 控件全选其中文字
- spring-使用配置文件完成JdbcTemplate操作数据库
- MySQL数据库的datetime与timestamp
- cacti 被监控机器snmp 配置
- 构建LAMP平台及应用系统
- Jfinal 显示欢迎页 index.jsp
- “人肉”背后隐藏的网络风险
- 如何进行服务器选购[转]