noodleProblems/
Binary Tree Inorder Traversal
#18

Binary Tree Inorder Traversal

AlgorithmeasyStackTreeDepth First SearchBinary Tree

Given the root of a binary tree, return the **inorder** traversal of its nodes' values — left subtree, then node, then right subtree.

The tree is given as a level-order array where null marks a missing child: [1, null, 2, 3] is a root 1 whose right child is 2, and 2's left child is 3.

Example cases

  • right-leaning
    in root = [1,null,2,3]132
    out [1,3,2]
    Visit 1, then 2's left child 3, then 2.
  • empty
    in root = []null
    out []
  • single node
    in root = [1]1
    out [1]

Constraints

  • The number of nodes in the tree is in the range [0, 100].
  • -100 <= Node.val <= 100
Saved
root =
[1,null,2,3]