mirror of
https://github.com/CyC2018/Interview-Notebook.git
synced 2026-10-31 11:05:36 +00:00
Update 32.3 按之字形顺序打印二叉树.md
补充利用 reverse 标记交替翻转每层结果的解题思路说明。
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
|
||||
## 解题思路
|
||||
|
||||
在 [32.2](32.2%20把二叉树打印成多行.md) 按层输出的基础上,用 reverse 标记当前层的方向:第 1 层从左到右,第 2 层把这一层的 list 翻转后再加入结果,之后每层交替。
|
||||
|
||||
```java
|
||||
public List<List<Integer>> decorateRecord(TreeNode root) {
|
||||
List<List<Integer>> ret = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user