秒客网

秒客网
  • 首页
  • 网络编程
    • Java
    • C/C++
    • 编程技术
    • Android
    • C#
    • VB
    • R语言
    • JavaScript
    • Swift
    • IOS
    • PHP
    • ASP.NET
    • ASP
    • 正则表达式
    • 易语言
    • vb.net
    • C语言
    • Python
    • Golang
    • bat
    • VBS
    • perl
    • Lua
    • Dos
    • Ruby
    • VBA
    • PowerShell
    • Erlang
    • autoit
  • 网络运营
    • 建站经验
    • 网络安全
    • 网站优化
    • 网站运营
    • 站长资源
  • 数据库
    • Redis
    • Oracle
    • Mysql
    • Sql Server
    • Access
    • mariadb
    • DB2
    • PostgreSQL
    • Sqlite
    • MongoDB
    • 数据库技术
    • Mssql
  • 服务器系统
    • Linux
    • Ubuntu
    • Centos
    • Windows10
    • Windows7
    • 系统进程
    • Bios
    • Fedora
    • Windows11
    • Solaris
    • 注册表
    • windows server
  • 服务器技术
    • 云服务器
    • 虚拟主机
    • DNS服务器
    • Nginx
    • FTP服务器
    • 服务器其它
    • 服务器安全
    • WEB服务器
    • Tomcat
    • 邮件服务器
    • IIS
    • 虚拟服务器
  • 建站程序
    • Wordpress
    • 极致CMS
    • ZBLOG
    • PHPCMS
    • DEDECMS
    • 帝国CMS
    • Discuz
    • 苹果CMS
    • ECSHOP
    • CMS系统
  • 电脑知识
    • 网络技术
    • 组装电脑
    • 软件教程
    • 电脑硬件
  • 数码知识
    • 智能家居
    • 智能电视
    • 机顶盒
    • 智能音箱
    • 手表手环
    • VR/AR
    • VR之家
  • 游戏
    • 手机游戏
    • 单机游戏
    • 网络游戏
  • 综合资讯
    • 百科知识
当前位置: 首页 >Maximum Depth of Binary Tree

Maximum Depth of Binary Tree

时间:2023-03-09 14:57:07
Maximum Depth of Binary Tree

二叉树最大深度的递归实现。

/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
import java.lang.*;
public class Solution {
public int maxDepth(TreeNode root) {
int depth1;
int depth2;
if(root == null) return 0;
//左子树的深度
depth1 = maxDepth(root.right);
//右子树的深度
depth2 = maxDepth(root.left);
return Math.max(depth1,depth2)+1;
}
}

相关文章

  • 【题解】【BT】【Leetcode】Binary Tree Level Order Traversal
  • Binary Tree Zigzag Level Order Traversal,z字形遍历二叉树,得到每层访问的节点值。
  • LeetCode 110 Balanced Binary Tree(平衡二叉树)(*)
  • LeetCode 94:Binary Tree Inorder Traversal(中序遍历)
  • LeetCode: Recover Binary Search Tree 解题报告
  • [线索二叉树] [LeetCode] 不需要栈或者别的辅助空间,完成二叉树的中序遍历。题:Recover Binary Search Tree,Binary Tree Inorder Traversal
  • Construct Binary Tree from Inorder and Postorder Traversal (&&Preorder and Inorder Traversal )——数据结构和算法的基本问题
  • LeetCode算法题-Second Minimum Node In a Binary Tree(Java实现)
  • Binary Tree Preorder Traversal——经典算法的迭代求解(前序,中序,后序都在这里了)
  • 二叉树的前中后序的遍历(Binary Tree)c语言实现
上一篇:学习笔记——git
下一篇:mvc3 上传图片

推荐文章

  • JS中【querySelector】详解
  • arcgis图层的属性表乱码问题
  • mysql基础-数据库初始化操作必要步骤和客户端工具使用-记录(二)
  • Jupyter Notebook快捷键
  • 刷题DAY19
  • gdb远程debug A syntax error in expression, near `variable)'.
  • [转] ICRA2022 SLAM相关论文整理
  • Jupyter notebook快捷键看这一篇就够了
  • JS学习笔记-数组
  • Jupyter Notebook基础(5)快捷键说明、快捷键设置

相关下载

  • binary matrix with maximum branch number下载
  • Exact maximum a posteriori estimation for binary images下载
  • binary_tree下载
  • Binary Search Tree下载
  • binary_tree下载
  • 最新编程技术文章
  • 网站地图

Copyright © 2021-2022 www.miaokee.com 秒客网 备案号:粤ICP备2021167564号

免责声明:本站文章多为用户分享,部分搜集自互联网,如有侵权请联系站长,我们将在72小时内删除。

