AlgoFrames

Complete the in-order traversal

Warm-up · Fill in the code · about 5 min

Fill the three blanks so walk collects the values of a binary tree in in-order. Return the values as a list.

Example 1

Input:

[[1,null,2,3]]

Output:

[1,3,2]

In-order visits 1, then the left side of 2, which is 3, then 2.

Constraints

  • 0 ≤ number of nodes ≤ 1,000
  • -1,000 ≤ Node.val ≤ 1,000
  • The tree is given in level order; null marks a missing child

Learn the idea first: Pre-order, in-order, post-order, a visual lesson.

More Pre-order, in-order, post-order problems