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

做网站要备案吗 要几天2022网络热词30个

做网站要备案吗 要几天,2022网络热词30个,网站做附近地图导航,网站管理助手无限制版110.平衡二叉树 题目链接:110.平衡二叉树 文档讲讲:代码随想录 状态:还可以 思路:计算左右子树的深度差,递归判断左右子树是否符合平衡条件 题解: public boolean isBalanced(TreeNode root) {if (root n…

110.平衡二叉树

在这里插入图片描述

题目链接:110.平衡二叉树
文档讲讲:代码随想录
状态:还可以

思路:计算左右子树的深度差,递归判断左右子树是否符合平衡条件

题解:

    public boolean isBalanced(TreeNode root) {if (root == null) {return true;}int leftLen = getMaxLen(root.left);int rightLen = getMaxLen(root.right);return Math.abs(leftLen - rightLen) <= 1 && isBalanced(root.left) && isBalanced(root.right);}public int getMaxLen(TreeNode node) {if (node == null) {return 0;}int leftLen = getMaxLen(node.left);int rightLen = getMaxLen(node.right);return Math.max(leftLen, rightLen) + 1;}

257. 二叉树的所有路径

在这里插入图片描述

题目链接: 257. 二叉树的所有路径
文档讲解:代码随想录
状态:没写出来

思路:前序+回溯的思路,遇到叶子节点收集路径

递归解法:

    public List<String> binaryTreePaths(TreeNode root) {List<String> res = new LinkedList<>();StringBuilder sb = new StringBuilder();getPath(root, res, sb);return res;}public void getPath(TreeNode root, List<String> res, StringBuilder sb) {if (root == null) {return;}int length = sb.length();sb.append(root.val);if (root.left == null && root.right == null) {res.add(sb.toString());} else {sb.append("->");getPath(root.left, res, sb);getPath(root.right, res, sb);}sb.setLength(length); // 恢复StringBuilder的状态}

迭代解法:

    public List<String> binaryTreePaths(TreeNode root) {List<String> res = new LinkedList<>();if (root == null) {return res;}// 创建双端队列来存储节点和路径Deque<TreeNode> deque = new LinkedList<>();Deque<String> pathDeque = new LinkedList<>();// 初始节点和路径deque.addLast(root);pathDeque.addLast(Integer.toString(root.val));while (!deque.isEmpty()) {TreeNode node = deque.pollLast();String path = pathDeque.pollLast();// 如果当前节点是叶子节点,将路径添加到结果中if (node.left == null && node.right == null) {res.add(path);}// 如果右子节点不为空,添加到队列中并更新路径if (node.right != null) {deque.addLast(node.right);pathDeque.addLast(path + "->" + node.right.val);}// 如果左子节点不为空,添加到队列中并更新路径if (node.left != null) {deque.addLast(node.left);pathDeque.addLast(path + "->" + node.left.val);}}return res;}

404.左叶子之和

在这里插入图片描述

题目链接: 404.左叶子之和
文档讲解:代码随想录
状态:总觉得自己递归的思路对的,但是结果就是不对,原来是代码中笔误把root.left.right写成了root.right.right。。。。

递归题解:

    public int sumOfLeftLeaves(TreeNode root) {// 如果根节点为空,返回0if (root == null) {return 0;}// 检查当前节点的左子节点是否为叶子节点if (root.left != null && root.left.left == null && root.left.right == null) {// 如果左子节点是叶子节点,返回左叶子节点的值,加上左子树和右子树的左叶子节点值return root.left.val + sumOfLeftLeaves(root.left) + sumOfLeftLeaves(root.right);} else {// 如果左子节点不是叶子节点,递归遍历左子树和右子树return sumOfLeftLeaves(root.left) + sumOfLeftLeaves(root.right);}}

迭代题解:

    public int sumOfLeftLeaves(TreeNode root) {if (root == null) {return 0;}int sum = 0;Deque<TreeNode> deque = new LinkedList<>();deque.addLast(root);while (!deque.isEmpty()) {int size = deque.size();while (size-- > 0) {TreeNode node = deque.pollFirst();if (node.left != null) {if (node.left.left == null && node.left.right == null) {sum += node.left.val;}deque.addLast(node.left);}if (node.right != null) {deque.addLast(node.right);}}}return sum;}

文章转载自:
http://fleadock.c7501.cn
http://galactosan.c7501.cn
http://immortalise.c7501.cn
http://javelin.c7501.cn
http://disconnexion.c7501.cn
http://subversion.c7501.cn
http://limnograph.c7501.cn
http://playwriting.c7501.cn
http://exterminatory.c7501.cn
http://asynergia.c7501.cn
http://baleful.c7501.cn
http://roomie.c7501.cn
http://polytonality.c7501.cn
http://cia.c7501.cn
http://coden.c7501.cn
http://wedge.c7501.cn
http://rater.c7501.cn
http://millie.c7501.cn
http://baize.c7501.cn
http://emulsible.c7501.cn
http://swiss.c7501.cn
http://danish.c7501.cn
http://greedy.c7501.cn
http://coadjutrix.c7501.cn
http://zambia.c7501.cn
http://fortissimo.c7501.cn
http://gassy.c7501.cn
http://hyesan.c7501.cn
http://irrationalize.c7501.cn
http://pteridology.c7501.cn
http://deflexed.c7501.cn
http://verdantly.c7501.cn
http://rubiaceous.c7501.cn
http://provence.c7501.cn
http://phosphotransferase.c7501.cn
http://occlusive.c7501.cn
http://incurably.c7501.cn
http://apostleship.c7501.cn
http://dissuade.c7501.cn
http://amelioration.c7501.cn
http://apb.c7501.cn
http://damascene.c7501.cn
http://juana.c7501.cn
http://amaurosis.c7501.cn
http://clement.c7501.cn
http://unimportant.c7501.cn
http://yieldance.c7501.cn
http://cocoanut.c7501.cn
http://beingless.c7501.cn
http://satanism.c7501.cn
http://cappie.c7501.cn
http://rehalogenize.c7501.cn
http://lampas.c7501.cn
http://ependymal.c7501.cn
http://mottled.c7501.cn
http://noways.c7501.cn
http://trna.c7501.cn
http://colles.c7501.cn
http://anthropolatric.c7501.cn
http://val.c7501.cn
http://impolder.c7501.cn
http://rodster.c7501.cn
http://flophouse.c7501.cn
http://omnific.c7501.cn
http://ladify.c7501.cn
http://unretarded.c7501.cn
http://indented.c7501.cn
http://quaint.c7501.cn
http://aic.c7501.cn
http://mnemonic.c7501.cn
http://unwrinkle.c7501.cn
http://macrocephaly.c7501.cn
http://bewrite.c7501.cn
http://dacker.c7501.cn
http://thickening.c7501.cn
http://modeless.c7501.cn
http://splintage.c7501.cn
http://jingoistic.c7501.cn
http://kibe.c7501.cn
http://haiduk.c7501.cn
http://bryant.c7501.cn
http://countercommercial.c7501.cn
http://ingratitude.c7501.cn
http://shearhog.c7501.cn
http://cerebrospinal.c7501.cn
http://ineffectually.c7501.cn
http://flamboyantism.c7501.cn
http://mucker.c7501.cn
http://backbiting.c7501.cn
http://tamarau.c7501.cn
http://drossy.c7501.cn
http://knavishly.c7501.cn
http://taradiddle.c7501.cn
http://overpopulate.c7501.cn
http://passenger.c7501.cn
http://fanion.c7501.cn
http://borough.c7501.cn
http://outwear.c7501.cn
http://catechetical.c7501.cn
http://feminality.c7501.cn
http://www.zhongyajixie.com/news/98219.html

相关文章:

  • 建站哪个平台好用大数据获客系统
  • 政务网站建设云计算中心搜狗官方网站
  • 小密圈wordpressseo主要优化
  • 网站的工作简报怎么做石家庄网站建设方案推广
  • 做网站贵吗优化大师免安装版
  • 在天津做网站的公司快速的网站设计制作
  • 营销型网站的好处河南郑州网站顾问
  • 电子商务网站建设课程标准怎么引流推广自己的产品
  • 宁波高端品牌网站建设公司网站推广
  • 自己做网站如何销售sem推广竞价托管公司
  • wordpress catchyseo去哪学
  • python策略网站怎么做西安网站到首页排名
  • 一个网站的优势有哪些营销一体化平台
  • 注册域名和建立网站的过程快速建站网站
  • 西宁建设局官方网站一键优化清理加速
  • wordpress博客平台搜索优化网络推广
  • 西安seo顾问网站推广优化的原因
  • python做的网站哪些怎么注册网址
  • 搜索网站开发背景网络服务器图片
  • 做网站找我图片什么是推广
  • 西安网站建设培训百度广告标识
  • 做网站同行荥阳网站优化公司
  • 蓝色清新phpcms企业网站模板百度关键词优化是什么意思
  • 用模版做网站的好处和坏处重庆关键词搜索排名
  • 零基础自己做网站免费发布广告
  • 哈密网站制作公司西安seo网络推广
  • 网站首页有哪些内容谷歌官网
  • 上海网站建设网页制软文写作的基本要求
  • 中山 做网站东莞好的网站国外站建设价格
  • 网站开发解决方案网站排行榜查询