Skip to content
Veltoryx Technologies
ProProblem 97● MediumLeetCode #103 ↗3 min readUpdated 30 October 2026

Binary Tree Zigzag Level Order Traversal

Return zigzag level order traversal of a binary tree using BFS with alternating addFirst and addLast.

01The problem

Given the root of a binary tree, return the zigzag level order traversal of its nodes' values (i.e., from left to right, then right to left for the next level and alternate between).

text
        1
      /        2     3
    / \   /    4   5 6   7

Output: [[1], [3, 2], [4, 5, 6, 7]]

Constraints

  • The number of nodes in the tree is in the range [0, 2000].
  • -1000 <= Node.val <= 1000

Loading the rest of the lesson…