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

做网站页面需要的资料建设监理协会官方网站

做网站页面需要的资料,建设监理协会官方网站,网站如何备案icp,wordpress下载主题下载目录 题目1- 思路2- 实现⭐103. 二叉树的锯齿形层序遍历——题解思路 2- ACM实现 题目 原题连接#xff1a;103. 二叉树的锯齿形层序遍历 1- 思路 二叉树的层序遍历#xff0c;遇到奇数时#xff0c;利用 Collections.reverse() 翻转即可 2- 实现 ⭐103. 二叉树的锯齿形层… 目录 题目1- 思路2- 实现⭐103. 二叉树的锯齿形层序遍历——题解思路 2- ACM实现 题目 原题连接103. 二叉树的锯齿形层序遍历 1- 思路 二叉树的层序遍历遇到奇数时利用 Collections.reverse() 翻转即可 2- 实现 ⭐103. 二叉树的锯齿形层序遍历——题解思路 class Solution {public ListListInteger res new ArrayList();public ListListInteger zigzagLevelOrder(TreeNode root) {return Traversal(root);}public ListListInteger Traversal(TreeNode root){if(rootnull){return res;}// 借助 queueQueueTreeNode queue new LinkedList();queue.offer(root);// queue 不空int count 0;while(!queue.isEmpty()){int len queue.size();ListInteger path new ArrayList();while(len0){TreeNode node queue.poll();path.add(node.val);if(node.left!null){queue.offer(node.left);}if(node.right!null){queue.offer(node.right);}len--;}count;if(count%21){res.add(new ArrayList(path));}else{Collections.reverse(path);res.add(new ArrayList(path));}}return res;} }2- ACM实现 public class levelTraversal {static class TreeNode{int val;TreeNode left;TreeNode right;TreeNode(){}TreeNode(int x){val x;}}public static TreeNode build(Integer[] nums){QueueTreeNode queue new LinkedList();TreeNode root new TreeNode(nums[0]);queue.offer(root);int index 1;while(!queue.isEmpty() indexnums.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 levelTraversal(TreeNode root){if(rootnull) {return res;}QueueTreeNode queue new LinkedList();queue.offer(root);int level 0;while(!queue.isEmpty()){ListInteger iterm new ArrayList();int len queue.size();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--;}if(level%21) {Collections.reverse(iterm);}res.add(new ArrayList(iterm));}return res;}public static void main(String[] args) {Scanner sc new Scanner(System.in);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);levelTraversal(root);System.out.println(结果为res.toString());} }
http://www.hkea.cn/news/14342879/

相关文章:

  • 忠益网站建设wordpress手机主题mip
  • 可视化的网站开发工具品牌推广外包公司
  • 网站建设维护要加班吗三联网站建设工作室
  • 手机网站开发 1433端口错误企业档案网站建设
  • 中科时代建设官方网站个人网站要求
  • win7 iis网站无法显示该页面郑州seo外包费用
  • wdcp新建网站做网站一般用什么程序
  • 白云网站 建设信科网络动画网站建设
  • 中兴的网站谁做的网站开发技术发展历程
  • 住建网站需多少钱wordpress浮动音乐
  • 东莞优化网站制作广东省建设网官网
  • 做网站需要准备什么wordpress后台密码忘了
  • 兼职做效果图的网站九江城乡建设网站为什么打不开
  • 苏州免费模板建站论文收录网站
  • 济南企业建站排行榜专业网络推广平台
  • 手机和pc合一的网站建材 网站 模板
  • 艺纵网站建设网咯鸟深圳网站建设
  • 公众号开发是什么seo排名工具快速提高
  • 大连网站建站华文细黑做网站有版权吗
  • 个人可以做的外贸网站网站建设费是业务宣传费吗
  • 网站建设评分安徽省建设安全协会网站
  • 企业网站建设价格表网站公网安备链接怎么做
  • 南宁网站设计公司排名整合营销公司排名
  • 多说与网站账号绑定科技 响应式网站模板下载
  • 网站制作:网推宝|百度做邀请函好的网站
  • 做星座网站西安网络技术有限公司网站
  • 网站安全狗服务名北京注册公司地址有什么要求
  • 鹰潭网站设计外贸soho建站多少钱
  • 网站后台管理系统代码旅游网站的设计方案怎么做
  • 网站服务理念适合机械网站的wordpress主题模板