mirror of
https://github.com/CyC2018/Interview-Notebook.git
synced 2026-10-30 18:23:52 +00:00
Update 32.2 把二叉树打印成多行.md
题目链接改为力扣中的对应题目,题目描述和代码按该题的接口调整。
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# 32.2 把二叉树打印成多行
|
||||
|
||||
[NowCoder](https://www.nowcoder.com/practice/445c44d982d04483b04a54f298796288?tpId=13&tqId=11213&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||
[Leetcode](https://leetcode.cn/problems/cong-shang-dao-xia-da-yin-er-cha-shu-ii-lcof/)
|
||||
|
||||
## 题目描述
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
## 解题思路
|
||||
|
||||
```java
|
||||
ArrayList<ArrayList<Integer>> Print(TreeNode pRoot) {
|
||||
ArrayList<ArrayList<Integer>> ret = new ArrayList<>();
|
||||
public List<List<Integer>> decorateRecord(TreeNode root) {
|
||||
List<List<Integer>> ret = new ArrayList<>();
|
||||
Queue<TreeNode> queue = new LinkedList<>();
|
||||
queue.add(pRoot);
|
||||
queue.add(root);
|
||||
while (!queue.isEmpty()) {
|
||||
ArrayList<Integer> list = new ArrayList<>();
|
||||
List<Integer> list = new ArrayList<>();
|
||||
int cnt = queue.size();
|
||||
while (cnt-- > 0) {
|
||||
TreeNode node = queue.poll();
|
||||
|
||||
Reference in New Issue
Block a user