49. Binary Tree Inorder Traversal

Return the in-order traversal of a binary tree: left subtree, then the node, then the right subtree. Try it iteratively too.

Example 1

Input: root = [1,null,2,3]
Output: [1,3,2]

Example 2

Input: root = []
Output: []
Hint 1

Recursive version: inorder(left), visit, inorder(right).

Hint 2

Iterative: a stack replaces the call stack.

TreeStack