loading

Binary Tree Zigzag Level Order Traversal — Step-by-Step Visualization

mediumLeetCode #103TreeBFSBinary Tree

Return zigzag level order traversal (left-to-right, then right-to-left alternating).

Algorithm Pattern

BFS + Direction Toggle

Key Idea

Standard BFS but reverse alternate levels.

Step-by-Step Approach

  1. BFS level by level
  2. Even levels: left to right
  3. Odd levels: reverse the level

Related Problems