二叉树的层级遍历
来源:互联网 发布:计算机二级vb视频教程 编辑:程序博客网 时间:2024/06/05 04:17
public class TreeNode { int val = 0; TreeNode left = null; TreeNode right = null; public TreeNode(int val) { this.val = val; }}public ArrayList<Integer> PrintFromTopToBottom(TreeNode root) { ArrayList<Integer> result = new ArrayList<Integer>(); if(root == null)return result; Queue<TreeNode> que = new LinkedList<TreeNode>(); //result.add(root.val); que.add(root); while(!que.isEmpty()){ TreeNode t = que.remove(); if(t.left != null)que.add(t.left); if(t.right != null)que.add(t.right); result.add(t.val); } return result; }
0 0
- 二叉树的层级遍历
- 二叉树的层级遍历
- 层级遍历二叉树
- 二叉树-层级遍历
- 二叉树的层级遍历 java
- <LeetCode> 题69~71: 二叉树的层级遍历
- 树的层级遍历
- 层级二叉树实现与遍历
- 树结构的层级遍历
- Java实现二叉树的先序、中序、后序、层级遍历
- LeetCode 102 Binary Tree Level Order Traversal(二叉树的层级顺序遍历)(*)
- Java实现二叉树的先序、中序、后序、层级遍历
- Binary Tree Level Order Traversal, 二叉树层级遍历
- 二叉树层级遍历并按行打印
- 二叉树层级遍历之每层最后一个值
- 二叉树的遍历算法(先序中序后序遍历的递归算法与非递归算法、层级遍历的递归与非递归算法)
- LeetCode 107 Binary Tree Level Order Traversal II(二叉树的层级顺序遍历2)(*)
- 二叉树的遍历
- JVM调优总结(十)-调优方法
- 基于kubernetes和SpringCloud微服务构建方案
- ios 判断app程序第一次启动方法
- JAVA从入门到精通(4)
- 在Express的页面模板中的变量的定义与使用总结
- 二叉树的层级遍历
- java异常体系____异常简介及其架构
- 问题.沉浸式状态下输入框会被软键盘覆盖解决办法
- JVM调优总结(九)-新一代的垃圾回收算法
- PHP填坑——类与对象
- jsp 基础页面
- Logistic回归
- Collection、Map两大基础回顾(本篇为Map)
- 此博文目录有几个解决问题的思路可以借鉴