递归求二叉树的最大深度。

/*** 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相关推荐

  1. LeetCode——Maximum Depth of Binary Tree

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

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

  3. Leetcode: Maximum Depth of Binary Tree

    题目:算出二叉树的最大深度 解决方案:(1)BFS (2)DFS (1)BFS 一层一层往下搜索,一直找到最深的点,这里由于节点的val是没有用的,所以可以用来存储当前节点的深度,然后注意指针一定要初 ...

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

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

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

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

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

  8. 领扣-104/111 二叉树的最大深度 Maximum Depth of Binary Tree MD

    Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...

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

最新文章

  1. Apache启动时报Could not reliably determine the server's fully qualified domain name
  2. SpringMVC处理模型数据
  3. vue的插值语法及el和data、methods语法释义
  4. YAML基础知识及搭建一台简洁版guestbook
  5. AdBoost算法详解
  6. JQuery Ajax传递整个表单数据方法
  7. UVA - 1605 Building for UN (联合国大楼)
  8. 从零打造一个程序员的mac
  9. 【分布式系统工程实现】系统可扩展性演化
  10. ionic4升级到ionic5踩坑记录
  11. 蓝牙sbc怎么解决_【科普】蓝牙音频常用的编解码格式
  12. 关闭默认共享-关于Windows的默认共享介绍
  13. 同一个基站连接两个核心网AMF POOL的场景分析及带AMF重选的注册流程
  14. mac电脑怎么彻底关闭系统更新提示?
  15. react+antd的后台管理项目模板
  16. Android Studio创建虚拟机选定指定位置
  17. python数据库-2
  18. 大数据级新闻去重实现 - 1.在线实时方案
  19. 2048小游戏逻辑代码(易懂)
  20. 用c语言编写两整数乘积,c语言两个数相乘求积 c语言输入两个整数求乘积

热门文章

  1. ACCEPT()和ACCEPT4()
  2. PHP也玩并发,巧用curl 并发减少后端访问时间
  3. 使用Cacti监控你的网络Cacti的安装
  4. 如何检查当TextBox设置为多行时是不是超长了?
  5. 使用 HttpResponse.Write 方法进行字符串串联
  6. tensorboard图上存在直线_高中数学必修二直线与圆:真是让我没想到,他俩的关系还挺不简单...
  7. 连接此产品到计算机并打开此产品电源,n6705c 直流电源分析仪.pdf
  8. php环境搭建 warmp_PHP环境搭建
  9. c++重载运算符_Chapter13:重载——入门(一)
  10. 华南理工大学计算机应用基础随堂作业,华南理工大学计算机应用基础随堂练习题目及答案...