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
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.