public TreeNode buildTree(int[] preorder, int[] inorder) {
        if(preorder.length == 0)
            return null;

        int pos = indexOf(inorder,preorder[0]);
        TreeNode node = new TreeNode(preorder[0]);
        //have left subTree
        if(pos >0){
            node.left  = buildTree(Arrays.copyOfRange(preorder,1,pos+1),
                    Arrays.copyOfRange(inorder,0,pos));
        }else
            node.left = null;
        // hava right subTree
        if(pos < preorder.length){
            node.right = buildTree(Arrays.copyOfRange(preorder,pos+1,preorder.length),
                    Arrays.copyOfRange(inorder,pos+1,inorder.length));
        }else
            node.right = null;

        return node;
    }