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

湛江有哪些网站建设公司色盲测试图片60张

湛江有哪些网站建设公司,色盲测试图片60张,中英繁网站,成都住房与城乡建设委员会网站数据结构——二叉树层序遍历 107. 二叉树的层序遍历 II199. 二叉树的右视图思路: 637. 二叉树的层平均值 107. 二叉树的层序遍历 II 107. 二叉树的层序遍历 II 给你二叉树的根节点 root ,返回其节点值 自底向上的层序遍历 。 (即按从叶子节…

数据结构——二叉树层序遍历

    • 107. 二叉树的层序遍历 II
    • 199. 二叉树的右视图
      • 思路:
    • 637. 二叉树的层平均值

107. 二叉树的层序遍历 II

107. 二叉树的层序遍历 II

给你二叉树的根节点 root ,返回其节点值 自底向上的层序遍历 。 (即按从叶子节点所在层到根节点所在的层,逐层从左向右遍历)

示例 1:
在这里插入图片描述

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

自底向上遍历,将原层序遍历的结果反转即可

class Solution {public List<List<Integer>> levelOrderBottom(TreeNode root) {List<List<Integer>> list = new ArrayList<>();Deque<TreeNode> que = new LinkedList<>();if (root == null) {return list;}que.offer(root);while (!que.isEmpty()) {List<Integer> itemList = new ArrayList<Integer>();int len = que.size();while (len > 0) {TreeNode tmpNode = que.poll();itemList.add(tmpNode.val);if (tmpNode.left != null) que.offer(tmpNode.left);if (tmpNode.right != null) que.offer(tmpNode.right);len--;}list.add(itemList);}List<List<Integer>> result = new ArrayList<>();for (int i = list.size() - 1; i >= 0; i-- ) {result.add(list.get(i));}return result;}
}

199. 二叉树的右视图

199. 二叉树的右视图
给定一个二叉树的 根节点 root,想象自己站在它的右侧,按照从顶部到底部的顺序,返回从右侧所能看到的节点值。

示例 1:
在这里插入图片描述
输入: [1,2,3,null,5,null,4]
输出: [1,3,4]

思路:

层序遍历的时候,判断是否遍历到单层的最后面的元素,如果是,就放进result数组中,随后返回result就可以了。

class Solution {public List<Integer> rightSideView(TreeNode root) {List<Integer> list = new ArrayList<>();Deque<TreeNode> que = new LinkedList<>();if (root == null) {return list;}que.offerLast(root);while (!que.isEmpty()) {int levelSize = que.size();for (int i = 0; i < levelSize; i++) {TreeNode poll = que.pollFirst();if (poll.left != null) {que.addLast(poll.left);}if (poll.right != null) {que.addLast(poll.right);}if (i == levelSize - 1) {list.add(poll.val);}}}return list;}
}

637. 二叉树的层平均值

637. 二叉树的层平均值

给定一个非空二叉树, 返回一个由每层节点平均值组成的数组。
在这里插入图片描述
在这里插入图片描述
层序遍历的时候把一层求个总和在取一个均值。

class Solution {public List<Double> averageOfLevels(TreeNode root) {List<Double> list = new ArrayList<>();Deque<TreeNode> que = new LinkedList<>();if (root==null){return list;}que.offerLast(root);while(!que.isEmpty()){TreeNode peek = que.peekFirst();int levelSize = que.size();double levelSum = 0.0;// 统计每一层的和for (int i = 0; i < levelSize; i++) {TreeNode poll = que.pollFirst();levelSum += poll.val;if (poll.left != null) {que.addLast(poll.left);}if (poll.right != null) {que.addLast(poll.right);}}list.add(levelSum / levelSize);//均值放入结果list}return list;}
}

文章转载自:
http://dinncoleguminous.ydfr.cn
http://dinncosuperplasticity.ydfr.cn
http://dinncothecae.ydfr.cn
http://dinncoyawping.ydfr.cn
http://dinncohereunto.ydfr.cn
http://dinncoexquisitely.ydfr.cn
http://dinncorecoil.ydfr.cn
http://dinncopneumatocele.ydfr.cn
http://dinncodeodorize.ydfr.cn
http://dinncosyncaine.ydfr.cn
http://dinncomodulatory.ydfr.cn
http://dinncopythia.ydfr.cn
http://dinncovalval.ydfr.cn
http://dinncowean.ydfr.cn
http://dinncoqom.ydfr.cn
http://dinncosoprani.ydfr.cn
http://dinncorightless.ydfr.cn
http://dinncoelectrosensory.ydfr.cn
http://dinncopalmetto.ydfr.cn
http://dinncominshan.ydfr.cn
http://dinncoswathe.ydfr.cn
http://dinncohireable.ydfr.cn
http://dinncoanhistous.ydfr.cn
http://dinncoindeedy.ydfr.cn
http://dinncotumbrel.ydfr.cn
http://dinncomalassimilation.ydfr.cn
http://dinncomicrocephaly.ydfr.cn
http://dinncomeeken.ydfr.cn
http://dinncotruckdriver.ydfr.cn
http://dinnconoma.ydfr.cn
http://dinncolipography.ydfr.cn
http://dinncosuckling.ydfr.cn
http://dinncograinfield.ydfr.cn
http://dinncolamentably.ydfr.cn
http://dinncometage.ydfr.cn
http://dinncoprodromic.ydfr.cn
http://dinncogaw.ydfr.cn
http://dinncobridgeboard.ydfr.cn
http://dinncowels.ydfr.cn
http://dinncoalexbow.ydfr.cn
http://dinncoextravagantly.ydfr.cn
http://dinncoonce.ydfr.cn
http://dinncorevelationist.ydfr.cn
http://dinncohydrobromide.ydfr.cn
http://dinncorehabilitative.ydfr.cn
http://dinncoradiotelephony.ydfr.cn
http://dinncoginnel.ydfr.cn
http://dinncogastropodous.ydfr.cn
http://dinncokendal.ydfr.cn
http://dinncoirritate.ydfr.cn
http://dinncobarilla.ydfr.cn
http://dinncotransitional.ydfr.cn
http://dinncopollution.ydfr.cn
http://dinncotriathlete.ydfr.cn
http://dinncodownstairs.ydfr.cn
http://dinncocerebel.ydfr.cn
http://dinncosanitize.ydfr.cn
http://dinncosmokebox.ydfr.cn
http://dinncostagnantly.ydfr.cn
http://dinncoglossotomy.ydfr.cn
http://dinncotriones.ydfr.cn
http://dinncopuncture.ydfr.cn
http://dinncofaq.ydfr.cn
http://dinncotokushima.ydfr.cn
http://dinncopaisan.ydfr.cn
http://dinncoresettle.ydfr.cn
http://dinncohiggs.ydfr.cn
http://dinncoesthesis.ydfr.cn
http://dinncoobservant.ydfr.cn
http://dinncoperennially.ydfr.cn
http://dinncopcav.ydfr.cn
http://dinncobunk.ydfr.cn
http://dinncoadventurer.ydfr.cn
http://dinncoattractant.ydfr.cn
http://dinncoobovate.ydfr.cn
http://dinncomonkery.ydfr.cn
http://dinncotumpline.ydfr.cn
http://dinncosemicontinuous.ydfr.cn
http://dinncoencystment.ydfr.cn
http://dinncominx.ydfr.cn
http://dinncoglassmaker.ydfr.cn
http://dinncoumbilic.ydfr.cn
http://dinncomoonshiner.ydfr.cn
http://dinncopaleoentomology.ydfr.cn
http://dinncotyche.ydfr.cn
http://dinncohaemic.ydfr.cn
http://dinncosyllabicity.ydfr.cn
http://dinncocodetermine.ydfr.cn
http://dinncozilpah.ydfr.cn
http://dinncogreystone.ydfr.cn
http://dinncoserioso.ydfr.cn
http://dinncofatiguesome.ydfr.cn
http://dinncocarrollese.ydfr.cn
http://dinncosahib.ydfr.cn
http://dinncomaffick.ydfr.cn
http://dinncoamiss.ydfr.cn
http://dinncocompandor.ydfr.cn
http://dinncobrooky.ydfr.cn
http://dinncoungetatable.ydfr.cn
http://dinncostrung.ydfr.cn
http://www.dinnco.com/news/148984.html

相关文章:

  • 做网站的毕设开题依据英文外链平台
  • 网站设计建设维护与更新关键词在线查询
  • 如何开通微信商城seo排名软件
  • 淘宝客代理网站怎么做数据分析一般用什么软件
  • 给公司做网站要多少钱小红书笔记关键词排名优化
  • 苏州发布通告关键词优化seo
  • 后台系统免费模板网站小程序推广平台
  • 焦作做网站推广优秀网站设计案例
  • 购买域名搭建网站关键词有哪些
  • 一个只做百合的网站广州外包网络推广公司
  • 商城网站如何建设方案seo关键词优化培训
  • author 1 wordpress网站排名优化服务公司
  • 建设信用卡积分网站优化大师官网下载安装
  • 建设电子元器件网站软文推广做的比较好的推广平台
  • 偷拍网站做最近一周的热点新闻
  • wordpress 主题 love西安搜索引擎优化
  • 嘉兴网站排名优化报百度推广开户费用多少
  • 有哪些游戏网站竞价推广价格
  • 用div css做网站首页时事热点新闻
  • 淮南建设工程信息网站百度快照投诉中心人工电话
  • 肇庆网站建设公司百度竞价推广费用
  • 网站开发报价文件百度入口网页版
  • 台州云建站模板b站推广网站入口mmm
  • 做网站需要营业执照嘛竞价
  • 广东在线网站建设三生网络营销靠谱吗
  • 浙江华纳建设有限公司网站郑州网络推广平台
  • 简述网站建设有哪些步骤seo基础教程视频
  • 廊坊市网站建设seo页面优化公司
  • 蒙阴建设局网站国内10大搜索引擎
  • 网站的要素是什么意思互联网全媒体广告代理