def big_l_prime_array(p, n):
    """
    Generate L' array using pattern and N array, Theorem 0.2.2
    L'[i] = largest index j less than n such that N[j] = |P[i:]|
    :param p: the pattern
    :param n: the N array
    :return: the L' array
    """
    lp = [0] * len(p)
    for j in range(len(p)):
        i = len(p) - n[j]
        if i < len(p):
            lp[i] = j + 1
    return lp