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

什么亲子网站可以做一下广告词长城宽带做网站

什么亲子网站可以做一下广告词,长城宽带做网站,开设类似于京东商城这类购物网站,汕头专业的开发网站方案目录 题目1-思路2- 实现⭐102. 二叉树的层序遍历——题解思路 3- ACM实现3-1 二叉树构造3-2 整体实现 题目 原题连接#xff1a;102. 二叉树的层序遍历 1-思路 1.借助队列 Queue #xff0c;每次利用 ①while 循环遍历当前层结点#xff0c;②将当前层结点的下层结点放入 … 目录 题目1-思路2- 实现⭐102. 二叉树的层序遍历——题解思路 3- ACM实现3-1 二叉树构造3-2 整体实现 题目 原题连接102. 二叉树的层序遍历 1-思路 1.借助队列 Queue 每次利用 ①while 循环遍历当前层结点②将当前层结点的下层结点放入 Queue中2.每遍历一个结点将值收集到 iterm 中每一层遍历完将结果存到 res 中 2- 实现 ⭐102. 二叉树的层序遍历——题解思路 class Solution {// 结果ListListInteger res new ArrayList();public ListListInteger levelOrder(TreeNode root) {QueueTreeNode queue new LinkedList();if(rootnull){return res;}queue.offer(root);while(!queue.isEmpty()){int len queue.size();ListInteger iterm new ArrayList();while(len0){TreeNode node queue.poll();iterm.add(node.val);if(node.left!null){queue.offer(node.left);}if(node.right!null){queue.offer(node.right);}len--;}res.add(new ArrayList(iterm));}return res;} }3- ACM实现 3-1 二叉树构造 public static TreeNode build(Integer[] nums){// 借助 queue 来实现二叉树构造QueueTreeNode queue new LinkedList();TreeNode root new TreeNode(nums[0]);queue.offer(root);int index 1;while (!queue.isEmpty() index nums.length){TreeNode node queue.poll();if(nums[index]!null indexnums.length){node.left new TreeNode(nums[index]);queue.offer(node.left);}index;if (nums[index]!null indexnums.length){node.right new TreeNode(nums[index]);queue.offer(node.right);}index;}return root; }3-2 整体实现 public class levelTraversal {static class TreeNode{int val;TreeNode left;TreeNode right;TreeNode(){}TreeNode(int x){val x;}}public static TreeNode build(Integer[] nums){// 借助 queue 来实现二叉树构造QueueTreeNode queue new LinkedList();TreeNode root new TreeNode(nums[0]);queue.offer(root);int index 1;while (!queue.isEmpty() index nums.length){TreeNode node queue.poll();if(nums[index]!null indexnums.length){node.left new TreeNode(nums[index]);queue.offer(node.left);}index;if (nums[index]!null indexnums.length){node.right new TreeNode(nums[index]);queue.offer(node.right);}index;}return root;}static ListListInteger res new ArrayList();public static ListListInteger levelOrder(TreeNode root) {QueueTreeNode queue new LinkedList();if(rootnull){return res;}queue.offer(root);while(!queue.isEmpty()){int len queue.size();ListInteger iterm new ArrayList();while(len0){TreeNode node queue.poll();iterm.add(node.val);if(node.left!null){queue.offer(node.left);}if(node.right!null){queue.offer(node.right);}len--;}res.add(new ArrayList(iterm));}return res;}public static void main(String[] args) {Scanner sc new Scanner(System.in);System.out.println(输入二叉树构造数组);String input sc.nextLine();input input.replace([,);input input.replace(],);String[] parts input.split(,);Integer[] nums new Integer[parts.length];for(int i 0 ; i parts.length;i){if(!parts[i].equals(null)){nums[i] Integer.parseInt(parts[i]);}else{nums[i] null;}}TreeNode root build(nums);ListListInteger forRes levelOrder(root);for(ListInteger i:forRes){System.out.println(i.toString());}}}
http://www.dnsts.com.cn/news/129254.html

相关文章:

  • 虚拟主机 视频网站wordpress 插件 喜欢
  • html设计素材网站国家企业信用网(江苏)
  • 做网站公司郑州句容建设局网站
  • 北京哪家制作网站好沈阳网站制作方法
  • 潍坊seo按天收费鞍山做网站优化
  • 做软件常用的网站做桂林网站的图片大全
  • 网站找人做seo然后网站搜不到了南京cms建站系统
  • 太原晋民网站建设公司帮人做网站在徐州被敲诈五万
  • 兰州做网站公司有哪些黑色星期五wordpress
  • 哪个网站是做安全教育中国万网网站建设服务
  • 一流 北京网站建设网站服务器的采购方案
  • 贵阳网站优化公司wordpress5.2 icp备案号
  • 深圳贸易网站建设网页制作dw软件
  • 现在由哪些网站可以做外链做网站需要什么技术员
  • 旅游网站对比模板上海注册公司流程及费用
  • 网站备案在哪里找惠州宣传片制作公司
  • 毕业答辩为什么做网站做网站最好用的软件
  • 黄山市非遗网站策划书帝国做网站的步骤
  • 网站标题分隔符号央视网商城网站建设
  • 如何建立一个小程序的网站深圳平湖网站开发
  • 做ppt一般在什么网站好合肥网站建设博客
  • 公司建推广网站多少钱网站设计制作报价图片欣赏
  • php数据库的网站模板代理网络是什么意思
  • 网站建设可视化避免视觉效果混淆。
  • 设计做兼职的网站求推荐如何规划设计一个网站
  • thinkphp网站开发实例教程建设网站需要做的工作
  • 成都网站建设方案优化做网站后台系统的规范
  • 网站页面footer的copy网页制作专业名词
  • 网站查询系统怎么做idc机房托管费用
  • 建设网站美海房地产wordpress 面板