Medium · Trees

Binary Tree Traversal Iteratively

Given the root of a binary tree, return its in-order traversal (left subtree, node, right subtree) as a list of values, computed without recursion; an empty tree returns [].

Examples

Example 1

{
  "tree": [1, 2, 3, 4, 5]
}

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

Example 2

{
  "tree": [2, 1, 3, null, null, null, 4]
}

Output: [1, 2, 3, 4]

Rebuild it in the studio

Core interview problems are free with a full runner and lessons; Pro opens the complete library.

More Trees problems