LeetCode - Maximum Depth of Binary Tree
递归求二叉树的最大深度。
/*** Definition for binary tree* 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;if(root == null)return 0;int l = maxDepth(root.left);int r = maxDepth(root.right);if(l > r) return l+1;else return r+1;}}
LeetCode - Maximum Depth of Binary Tree相关推荐
- LeetCode——Maximum Depth of Binary Tree
LeetCode--Maximum Depth of Binary Tree Question Given a binary tree, find its maximum depth. The max ...
- LeetCode 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: Maximum Depth of Binary Tree
题目:算出二叉树的最大深度 解决方案:(1)BFS (2)DFS (1)BFS 一层一层往下搜索,一直找到最深的点,这里由于节点的val是没有用的,所以可以用来存储当前节点的深度,然后注意指针一定要初 ...
- 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 ...
- 【LeetCode 剑指offer刷题】树题4:104 Maximum Depth of Binary Tree
[LeetCode & 剑指offer 刷题笔记]目录(持续更新中...) 104. Maximum Depth of Binary Tree Given a binary tree, fin ...
- 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】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 ...
- 领扣-104/111 二叉树的最大深度 Maximum Depth of Binary Tree MD
Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...
- 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 ...
最新文章
- Apache启动时报Could not reliably determine the server's fully qualified domain name
- SpringMVC处理模型数据
- vue的插值语法及el和data、methods语法释义
- YAML基础知识及搭建一台简洁版guestbook
- AdBoost算法详解
- JQuery Ajax传递整个表单数据方法
- UVA - 1605 Building for UN (联合国大楼)
- 从零打造一个程序员的mac
- 【分布式系统工程实现】系统可扩展性演化
- ionic4升级到ionic5踩坑记录
- 蓝牙sbc怎么解决_【科普】蓝牙音频常用的编解码格式
- 关闭默认共享-关于Windows的默认共享介绍
- 同一个基站连接两个核心网AMF POOL的场景分析及带AMF重选的注册流程
- mac电脑怎么彻底关闭系统更新提示?
- react+antd的后台管理项目模板
- Android Studio创建虚拟机选定指定位置
- python数据库-2
- 大数据级新闻去重实现 - 1.在线实时方案
- 2048小游戏逻辑代码(易懂)
- 用c语言编写两整数乘积,c语言两个数相乘求积 c语言输入两个整数求乘积
热门文章
- ACCEPT()和ACCEPT4()
- PHP也玩并发,巧用curl 并发减少后端访问时间
- 使用Cacti监控你的网络Cacti的安装
- 如何检查当TextBox设置为多行时是不是超长了?
- 使用 HttpResponse.Write 方法进行字符串串联
- tensorboard图上存在直线_高中数学必修二直线与圆:真是让我没想到,他俩的关系还挺不简单...
- 连接此产品到计算机并打开此产品电源,n6705c 直流电源分析仪.pdf
- php环境搭建 warmp_PHP环境搭建
- c++重载运算符_Chapter13:重载——入门(一)
- 华南理工大学计算机应用基础随堂作业,华南理工大学计算机应用基础随堂练习题目及答案...