dsa · medium

Binary Tree Zigzag Level Order

GreyOrangeTreeQueue

Level-order values, alternating left-to-right and right-to-left.

Arguments

**Example:** [3,[9,None,None],[20,[15,None,None],[7,None,None]]][[3],[20,9],[15,7]].

Constraints

Number of nodes in [0, 2000] Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.

Examples

Example 1

Input:
[3,[9,None,None],[20,[15,None,None],[7,None,None]]]

Expected:
[[3],[20,9],[15,7]]

Open in the Dojo editor