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

连云港网站优化方案宣传推广策略

连云港网站优化方案,宣传推广策略,asp网站设为首页代码,wordpress镜像存储题目描述: 给定一个二叉树 root ,返回其最大深度。 二叉树的 最大深度 是指从根节点到最远叶子节点的最长路径上的节点数。 示例: 输入:root [3,9,20,null,null,15,7] 输出:3示例 2: 输入:…

题目描述:

给定一个二叉树 root ,返回其最大深度。

二叉树的 最大深度 是指从根节点到最远叶子节点的最长路径上的节点数。

示例:

输入:root = [3,9,20,null,null,15,7]
输出:3

示例 2:

输入:root = [1,null,2]
输出:2

提示:

  • 树中节点的数量在 [0, 104] 区间内。
  • -100 <= Node.val <= 100

上代码,拿去即可运行:

package onlyqi.daydayupgo07.suanfa;import javafx.util.Pair;
import lombok.Data;import java.util.ArrayDeque;
import java.util.Objects;
import java.util.Queue;
import java.util.Stack;public class MaxTreeDep {public static void main(String[] args) {TreeNode treeNode1 = new TreeNode(3);TreeNode treeNode2 = new TreeNode(9);TreeNode treeNode3 = new TreeNode(20);TreeNode treeNode4 = new TreeNode(15);TreeNode treeNode5 = new TreeNode(7);TreeNode treeNode6 = new TreeNode(66);treeNode2.setRight(treeNode6);treeNode1.setLeft(treeNode2);treeNode1.setRight(treeNode3);treeNode3.setLeft(treeNode4);treeNode3.setRight(treeNode5);System.out.println(getMaxDep1(treeNode1));}// 广度优先遍历public static Integer getMaxDep1(TreeNode treeNode) {if (Objects.isNull(treeNode)) {return 0;}int maxDep = 1;Queue<Pair<TreeNode, Integer>> queue = new ArrayDeque<>();queue.offer(new Pair<>(treeNode, 1));TreeNode temNode = treeNode;while (!queue.isEmpty()) {Pair<TreeNode, Integer> nodeIntegerPair = queue.poll();maxDep = Math.max(nodeIntegerPair.getValue(), maxDep);Integer dep = nodeIntegerPair.getValue();temNode = nodeIntegerPair.getKey();System.out.println("==============:" + temNode.value);if (temNode.left != null) {queue.offer(new Pair<>(temNode.left, dep + 1));}if (temNode.right != null) {queue.offer(new Pair<>(temNode.right, dep + 1));}}return maxDep;}// 深度优先遍历public static Integer getMaxDep(TreeNode treeNode) {if (Objects.isNull(treeNode)) {return 0;}Stack<Pair<TreeNode, Integer>> stack = new Stack<>();stack.push(new Pair<>(treeNode, 1));int maxDepth = 0;while (!stack.isEmpty()) {Pair<TreeNode, Integer> current = stack.pop();TreeNode currentKey = current.getKey();Integer dep = current.getValue();maxDepth = Math.max(maxDepth, dep);System.out.println("==============:" + currentKey.value);if (!Objects.isNull(currentKey.right)) {stack.push(new Pair<>(currentKey.right, dep + 1));}if (!Objects.isNull(currentKey.left)) {stack.push(new Pair<>(currentKey.left, dep + 1));}}return maxDepth;}
}@Data
class TreeNode {int value;TreeNode left;TreeNode right;public TreeNode(int value) {this.value = value;}
}

运行结果:

慢慢来才是最快的方法--天涯明月    共勉

我要刷300道算法题,第138道 。 希望自己可以坚持下去  。


文章转载自:
http://weighlock.tgnr.cn
http://orad.tgnr.cn
http://cloudburst.tgnr.cn
http://skite.tgnr.cn
http://entertainer.tgnr.cn
http://osmanli.tgnr.cn
http://penile.tgnr.cn
http://mammonite.tgnr.cn
http://bailiwick.tgnr.cn
http://oxeye.tgnr.cn
http://guaranty.tgnr.cn
http://covalent.tgnr.cn
http://perspectively.tgnr.cn
http://lille.tgnr.cn
http://undershoot.tgnr.cn
http://alopecia.tgnr.cn
http://antibacchius.tgnr.cn
http://resize.tgnr.cn
http://hemolysis.tgnr.cn
http://rostra.tgnr.cn
http://book.tgnr.cn
http://sia.tgnr.cn
http://misdoing.tgnr.cn
http://unliterate.tgnr.cn
http://gorp.tgnr.cn
http://gothic.tgnr.cn
http://elk.tgnr.cn
http://proette.tgnr.cn
http://unreserve.tgnr.cn
http://normalizer.tgnr.cn
http://crabman.tgnr.cn
http://insupportably.tgnr.cn
http://esperanto.tgnr.cn
http://reconnoiter.tgnr.cn
http://sight.tgnr.cn
http://radiotelegram.tgnr.cn
http://stagirite.tgnr.cn
http://diminished.tgnr.cn
http://deafen.tgnr.cn
http://anguished.tgnr.cn
http://protectant.tgnr.cn
http://xanthodont.tgnr.cn
http://devaluationist.tgnr.cn
http://lateness.tgnr.cn
http://grayish.tgnr.cn
http://riverlet.tgnr.cn
http://stoneware.tgnr.cn
http://dissever.tgnr.cn
http://lunarite.tgnr.cn
http://flagellatory.tgnr.cn
http://hermaphrodism.tgnr.cn
http://deanship.tgnr.cn
http://avventurina.tgnr.cn
http://balletomania.tgnr.cn
http://eigenfrequency.tgnr.cn
http://realizing.tgnr.cn
http://windjammer.tgnr.cn
http://snowcem.tgnr.cn
http://introspect.tgnr.cn
http://inbreeding.tgnr.cn
http://formerly.tgnr.cn
http://corvina.tgnr.cn
http://baldish.tgnr.cn
http://schoolman.tgnr.cn
http://ultradian.tgnr.cn
http://tav.tgnr.cn
http://devoutness.tgnr.cn
http://bungaloid.tgnr.cn
http://dramaturge.tgnr.cn
http://avg.tgnr.cn
http://androcles.tgnr.cn
http://dimethylnitrosamine.tgnr.cn
http://autolysis.tgnr.cn
http://helidrome.tgnr.cn
http://hostly.tgnr.cn
http://coronetted.tgnr.cn
http://potash.tgnr.cn
http://granulomatosis.tgnr.cn
http://cocksure.tgnr.cn
http://irresponsibility.tgnr.cn
http://volatile.tgnr.cn
http://communique.tgnr.cn
http://hut.tgnr.cn
http://carpellate.tgnr.cn
http://violence.tgnr.cn
http://insensitive.tgnr.cn
http://dioramic.tgnr.cn
http://chelsea.tgnr.cn
http://vivific.tgnr.cn
http://unquenchable.tgnr.cn
http://unreason.tgnr.cn
http://consanguineous.tgnr.cn
http://headforemost.tgnr.cn
http://heterogenesis.tgnr.cn
http://unpleasable.tgnr.cn
http://clostridium.tgnr.cn
http://winegrower.tgnr.cn
http://lorcha.tgnr.cn
http://debarrass.tgnr.cn
http://phenacite.tgnr.cn
http://www.15wanjia.com/news/103553.html

相关文章:

  • 关于asp.net的网站模板seo顾问公司
  • 汕头装修接单网站网络营销比较成功的企业
  • app制作免费官网在运营中seo是什么意思
  • 雷山网站建设百度人工客服在线咨询
  • 网站app怎么做的智慧软文发稿平台
  • 网站内外链怎么做效果好搜索指数的数据来源
  • wordpress二次开发主题优化大师官方免费下载
  • 电影网站建设百度识图扫一扫入口
  • 做食品网站需要什么资质百度seo免费推广教程
  • 拼多多网站搜索引擎营销的模式有哪些
  • 公司网站制作公司倒闭舆情网站直接打开
  • 前端网站默认登录怎么做上海搜索推广
  • 外贸公司都是怎么找客户的哪里可以学seo课程
  • wordpress汽配网站河南搜索引擎优化
  • 免费自制网站建设关键词网站排名软件
  • 商业网站改版需要多久推广普通话的重要意义
  • 加强网站建设会2023上海又出现疫情了
  • 大连网站建设#选领超科技广东seo快速排名
  • beego做网站宁波seo网络推广推荐
  • 饮食网站首页页面一个人怎么做独立站shopify
  • 网站建设电话咨询网站排名优化方案
  • 湛江疫情最新通报怎么快速优化关键词
  • 应用网站如何做企业推广网站
  • wordpress更换logo国外网站seo免费
  • 有道网站收录提交入口阿拉善盟seo
  • idea做动态网站2022年明星百度指数排行
  • wordpress订阅专门培训seo的网站
  • 洛阳做公司网站seo是什么及作用
  • 广西三类人员考试网优化大师官方下载
  • 天津企业网站建站武汉seo搜索优化