835. Inorder Traversal of Binary Tree

EasyTreesBinary TreeTraversalDFS

Given the root of a binary tree, return its inorder traversal (left subtree, node, right subtree) as an array of node values. The tree is given as a level-order array with null for missing children.

Input: A level-order array of the tree (null for missing nodes).

Output: Array — node values in inorder.

Examples

Example 1
Input: [1,2,3,4,5,null,6]
Output: [4,2,5,1,3,6]
Explanation: Left, root, right order.
Example 2
Input: [1]
Output: [1]
Explanation: Single node.
Example 3
Input: []
Output: []
Explanation: Empty tree.

Constraints

Asked by

TCSInfosysWiproCognizantCapgemini
Solve this problem in the editor →