AlgoLounge

Binary Tree Inorder Traversal

medium

Leetcode 94. Binary Tree Inorder Traversal

You are given the `root` of a binary tree, return the **inorder traversal** of its nodes' values.

Examples

Example 1

Input:  root = []
Output: []

Constraints

  • `0 <= number of nodes in the tree <= 100`
  • `-100 <= Node.val <= 100`

How the tests work: trees are written as level-order arrays — [1,null,2] is a root 1 with a right child 2. Your function receives real TreeNode objects.

TypeScript
Loading editor…
List of test cases (10)
Case 1
root = []
Case 2
root = [1,null,2,3]
Case 3
root = [1,2,3,4,5,null,6]
Case 4
root = [1]
Case 5
root = [1,2]
Case 6
root = [1,null,2]
Case 7
root = [5,3,7,2,4,6,8]
Case 8
root = [3,1,5,null,2,4,6]
Case 9
root = [10,5,15,null,null,12,20]
Case 10
root = [8,3,10,1,6,null,14,null,null,4,7,13]