public class Solution {
int i=0;
public TreeNode reConstructBinaryTree(int [] pre,int [] in) {
return constructBiTree(pre,in,0,pre.length-1);
}
public TreeNode constructBiTree(int pre[],int in[],int start,int end){
if(start>end)
return null;
TreeNode node = new TreeNode(pre[i]);
int index=Location(pre[i],in);
i++;
if(i>=pre.length)
return node;
node.left=constructBiTree(pre,in,start,index-1);
node.right=constructBiTree(pre,in,index+1,end);
return node;
}
public int Location(int target,int in[]){
int i=0;
for( i=0;i<in.length;i++){
if(target==in[i])
break;
}
return i;
}
}