#y1088. 二叉树_层序来回遍历

二叉树_层序来回遍历

【题目来源】
https://leetcode.cn/problems/binary-tree-zigzag-level-order-traversal/
给你二叉树 ,输出其节点值的层序遍历 。 (即先从左往右,再从右往左进行下一层遍历,以此类推,层与层之间交替进行)。 image

输入数据:

7

3 9 20 -1 -1 15 7

输出数据:

3

20 9

15 7

【说明】

-1表示没有节点

提示:

树中节点数目在范围 [0, 2000] 内

1<= Node.val <= 1000