Showing:
Handle Score
@Ibrahim Nash 6420
@mb1973 5578
@Quandray 5231
@akhayrutdinov 5111
@saiujwal13083 4510
@sanjay05 3762
@kirtidee18 3673
@marius_valentin_dragoi 3522
@sushant_a 3459
@verma_ji 3412
ZigZag Tree Traversal
Easy Accuracy: 49.78% Submissions: 26868 Points: 2

Given a Binary Tree. Find the Zig-Zag Level Order Traversal of the Binary Tree.

Example 1:

Input:
3
/   \
2     1
Output:
3 1 2


Example 2:

Input:
7
/     \
9       7
/  \     /
8    8   6
/  \
10   9
Output:
7 7 9 8 8 6 9 10 

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 <= 104