Problem Description
Given two binary trees T1 and T2, you have to find minimum number of insertions to be done in T1 to make it structurally identical to T2.
Return -1 if not possible.
First argument A denotes the root of tree T1.
Second argument B denotes the root of tree T2.
Return an integer denoting the above described output.
Input 1:
T1: 10 / \ 9 20T2: 5 / \ 2 7 / 1
Input 2:
T1: 10 / \ 9 20T2: 5 \ 7
Output 1:
1
Output 2:
-1
Explanation 1:
Insert a node into T1 as the left node of 9, it will be structurally identical to T2. Hence answer is 1.
Explanation 2:
You cannot make T1 and T2 structurally identical. Hence answer is -1.
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.