public TreeNode build(int[] preorder, int begin, int end, HashMap<Integer, Integer> hashMap, int hashStart, int hashEnd) {
        if (begin > end)
            return null;
        int val = preorder[begin];
        int index = hashMap.get(val);
        TreeNode root = new TreeNode(val);
        root.left = build(preorder, begin + 1, begin + index - hashStart, hashMap, hashStart, index - 1);
        root.right = build(preorder, begin + index - hashStart + 1, end, hashMap, index + 1, hashEnd);
        return root;
    }