• 2024-03-06【C++】求二叉树的最大深度和最小深度
    //求一颗二叉树的最大深度求高度:后序遍历求深度:前序遍历intmaxDepth(TreeNode*root){returnroot?1+max(maxDepth(root->left),maxDepth(root->right)):0;}//求一颗二叉树的最小深度(实质上是后序遍历)intminDepth(TreeNode*root){if(!root)retur
  • 2023-12-10111. 二叉树的最小深度
    目录题目完美踩坑题解题目给定一个二叉树,找出其最小深度。最小深度是从根节点到最近叶子节点的最短路径上的节点数量。示例1:输入:root=[3,9,20,null,null,15,7]输出:2示例2:输入:root=[2,null,3,null,4,null,5,null,6]输出:5完美踩坑之前好几个题做过求树的高
  • 2023-11-16【刷题笔记】111. Minimum Depth of Binary Tree
    题目Givenabinarytree,finditsminimumdepth.Theminimumdepthisthenumberofnodesalongtheshortestpathfromtherootnodedowntothenearestleafnode.Note: Aleafisanodewithnochildren.Example:Givenbinarytree [3,9,20,null,null,15,7],
  • 2023-09-22linux 中 find命令 -maxdepth 和 -mindepth 选项
     001、[root@pc1dir001]#lstest01test02ww.txtxx.map[root@pc1dir001]#tree.├──test01│  ├──cc.csv│  └──kk.txt├──test02│  ├──dirxx│  │  └──diryy│  │  ├──rr.ped│  │  └
  • 2023-06-05求树的最大深度,求树的最小深度
    树的深度       树的深度描述的树从根到当前节点的层级信息。求树的最大深度       解法:遍历所有的层级信息,找最大的。publicstaticintmaxDepth(TreeNoderoot){if(root==null){return0;}return1+Math.max(maxDepth(root.left),maxDep
  • 2022-11-30leetcode-111-easy
    MinimumDepthofBinaryTreeGivenabinarytree,finditsminimumdepth.Theminimumdepthisthenumberofnodesalongtheshortestpathfromtherootnode
  • 2022-10-12Find 过滤搜索、目录层级限制(-maxdepth、-mindepth)以及常用搜索技巧小结
    1)find过滤目录使用find命令在linux系统中查找文件时,有时需要忽略某些目录,可以使用"-path过滤的目录路径-prune-o"参数来进行过滤。不过必须注意:要忽略的路径参数要紧跟着
  • 2022-10-05二叉树的最小深度
    二叉树的最小深度一、题目描述给定一个二叉树,找出其最小深度。最小深度是从根节点到最近的叶子节点的最短路径上的节点数量。实例输入:root=[3,9,20,null,null,15,7]
  • 2022-09-21每日一结
    尤其注意递归的条件,分析好了各种情况。再下手写(不然堆积屎山堆积)。例如求二叉树的最小深度,就分三种情况。无子节点;有一个子节点;有两个子节点。那么就很明晰public int