当前位置: 首页 > news >正文

网站收录大量下降国内好点的wordpress主题

网站收录大量下降,国内好点的wordpress主题,网站建设功能图,长沙关键词优化Problem: 111. 二叉树的最小深度 文章目录 题目描述思路复杂度Code 题目描述 思路 1.欲望求出最短的路径#xff0c;先可以记录一个变量minDepth#xff0c;同时记录每次当前节点所在的层数currentDepth 2.在递的过程中#xff0c;每次递一层#xff0c;也即使当前又往下走… Problem: 111. 二叉树的最小深度 文章目录 题目描述思路复杂度Code 题目描述 思路 1.欲望求出最短的路径先可以记录一个变量minDepth同时记录每次当前节点所在的层数currentDepth 2.在递的过程中每次递一层也即使当前又往下走了一层则currentDepth当到达叶子节点时比较并取出min【minDepth, currentDepth】 3.在归的过程中因为是在往上层归则currentDepth– 4.返回最终的minDepth即可 复杂度 时间复杂度: O ( n ) O(n) O(n);其中 n n n为二叉树的节点个数 空间复杂度: O ( h ) O(h) O(h)最坏空间复杂度 Code DFS /*** Definition for a binary tree node.* public class TreeNode {* int val;* TreeNode left;* TreeNode right;* TreeNode() {}* TreeNode(int val) { this.val val; }* TreeNode(int val, TreeNode left, TreeNode right) {* this.val val;* this.left left;* this.right right;* }* }*/ class Solution {// record the minimum depth private int minDepth Integer.MAX_VALUE;// record the depth of the current node being traversedprivate int currentDepth 0;public int minDepth(TreeNode root) {if (root null) {return 0;}// start DFS traverssal from the root nodetravers(root);return minDepth;}private void travers(TreeNode root) {if (root null) {return;}// increase the current depth when entering a node in the preorder positioncurrentDepth;// if the current node is a leaf, update the minimum depthif (root.left null root.right null) {minDepth Math.min(minDepth, currentDepth);}travers(root.left);travers(root.right);// decrease the current depth when leaving a node in the postorder positioncurrentDepth--;} }
http://www.tj-hxxt.cn/news/138823.html

相关文章:

  • 搬家公司网站制作网站开发 软件有哪些
  • 响应式博客网站模板做导航网站赚钱吗
  • 淘宝网站的订单管理怎么做华意网站建设网络公司怎么样
  • 深圳华鑫峰网站建设惠州高端网站建设
  • 网页设计与网站建设在线第二章江西省城乡建设培训网官方网站
  • 西安建筑公司网站建设海尔网站建设推广
  • 做搜狗手机网站快速泉州wap网站制作
  • 网站开发的形式无锡本地网站
  • 网站ui设计为某公司或企业做的门户网站
  • 百度抓取网站图片相亲网站建设策划方案
  • 怎么样在公司配置服务器做网站线上电脑培训班
  • 拼多多网站建设方案珠海网站建设技术支持
  • wordpress赞助优化网站排名怎么样
  • 青岛外贸假发网站建设上海有哪些大型企业
  • 郑州 网站建设有限公司阿里网站
  • 关键词网站排名软件北京php培训网站建设
  • 宁波住房和城乡建设部网站owasp+网站开发
  • 怎么建设网站赚钱手机韩国展厅设计网站
  • 广东网站建站系统哪家好wordpress+取消边栏
  • 自己做的网站怎么发布到百度广州公司建站模板
  • 开发网站的意义微信小程序在哪里?
  • 上海市建设工程交易服务中心网站wordpress管理员登陆不上
  • 乐辰网站建设wordpress手机端兼容
  • 健身网站开发可行性分析网站制作免费软件
  • 商河网站建设公司手机网站制作平台有哪些
  • 开个免费的网站多少钱手机端模板网站
  • 金牛区建设局网站杭州网站建设报价
  • 广州网站建设制作价格天河建网站
  • 网站内容和备案不一样自助网站建设系统
  • wordpress网站首页链接乱码深圳 网站优化公司排名