def _build_lis(seq, prev, index_of_max_size) -> list:
    """Build the longest increasing subsequence from original sequence (list)
    seq, the list prev produced by the function longest_increasing_subsequence
    and index_of_max_size."""
    a = []

    while index_of_max_size != -1:
        a.append(seq[index_of_max_size])
        index_of_max_size = prev[index_of_max_size]

    a.reverse()
    return a