103_Binary Tree Zigzag Level Order Traversal
103. Binary Tree Zigzag Level Order Traversal
Question
Given a binary tree, return the zigzag level order traversal of its nodes' values.
(ie, from left to right, then right to left for the next level and alternate between).Example 1
Input:
3
/ \
9 20
/ \
15 7
Output:
[
[3],
[20,9],
[15,7]
]Idea (breadth-first search)
Solution : breadth-first search
Last updated