The idea is to construct the root node from the first element of the level order array. Find the index of this element in the in-order array.Recursively create the left subtree from the elements present on the left side to the current element in the in-order array. Similarly, create the right subtree from the elements present on the right side to the current element in the in-order array.
Below is the implementation of the above approach:
Output
4 8 10 12 14 20 22
Time Complexity: O(n^3) Auxiliary Space: O(n), where n is the number of nodes.