Zigzag level order traversal
Your task
Given a binary tree as a level-order array arr (null for missing), return its zigzag (boustrophedon) level-order traversal: the first level left to right, the second right to left, alternating thereafter. Return a list of lists of values, one per level. 0 <= node count <= 2000.
Examples
zigzag_level_order(arr: list[int]) -> list[list[int]]Example 1
Input
zigzag_level_order([3, 9, 20, None, None, 15, 7])Output
[[3], [20, 9], [15, 7]]