public TreeNode build(int begin, int end, int[] A) {
        if (begin > end)
            return null;
        int mid = begin + (end - begin) / 2;
        TreeNode root = new TreeNode(A[mid]);
        root.left = build(begin, mid - 1, A);
        root.right = build(mid + 1, end, A);
        return root;
    }