Medium Accuracy: 46.5% Submissions: 1824 Points: 4
Given two arrays that represent Preorder traversals of a Full binary tree preOrder and its mirror tree preOrderMirror(), your task is to complete the function constructBinaryTree(), that constructs the full binary tree using these two Preorder traversals.
Note: It is not possible to construct a general binary tree using these two traversal. But it is possible to create a full binary tree using the above traversals without any ambiguity. For more details refer to this article.
The function takes three arguments as input, first the array that represent Preorder traversals of a Full binary tree preOrder, second the array that represents the preorder traversal ofits mirror tree preOrderMirror() and last the size of both the array.
There will be T test cases and for each test case the function will be called separately.
For each test case the function must return the root to the new binary tree formed. Ouput will be the inorder traversal of the binary tree.