题目描述
Given a Binary Tree. Find the Zig-Zag Level Order Traversal of the Binary Tree.
Example 1:
Input:
1
/ \
2 3
/ \ / \
4 5 6 7
Output:
1 3 2 4 5 6 7
Example 2:
Input:
7
/ \
9 7
/ \ /
8 8 6
/ \
10 9
Output:
7 7 9 8 8 6 9 10
Your Task:
You don't need to read input or print anything. Your task is to complete the function zigZagTraversal() which takes the root node of the Binary Tree as its input and returns a list containing the node values as they appear in the Zig-Zag Level-Order Traversal of the Tree.
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(N).
Constraints:
1 <= N <= 10^{4}
输入格式
见题面
输出格式
见题面