def LZfactorization(LPF, string):
    """ Lempel-Ziv(LZ77) factorization, or s-factorization
    Ref: "Computing the Longest Previous Factor"
         (https://doi.org/10.1016/j.ejc.2012.07.011)
    """
    s_factorization = []
    ini_pos = 0
    while ini_pos < len(string):
        l = max(1, LPF[ini_pos])
        end_pos = ini_pos + l
        s_factorization.append(string[ini_pos:end_pos])
        ini_pos = end_pos
    return s_factorization
