...

/

Build Binary Tree from Preorder and Inorder Traversal

Build Binary Tree from Preorder and Inorder Traversal

Try to solve the Build Binary Tree from Preorder and Inorder Traversal problem.

Statement

Create a binary tree from two integer arrays, p_order and i_order, where p_order represents a preorder traversal of a binary tree, and i_order represents an inorder traversal of the same tree.

Constraints:

  • 11 \leq p_order.length, i_order.length 1000\leq1000
  • i_order.length ==== p_order.length
  • 1000-1000 \leq p_order[i], i_order[i] 1000\leq 1000
  • p_order and i_order consist of unique values.
  • Each value of i_order also appears in p_order and vice versa.

Examples

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy