import bisect


def compute_previous_intervals(I):
    """
    For every interval j, compute the rightmost mutually compatible interval
    i, where i < j I is a sorted list of Interval objects (sorted by finish
    time)
    """
    # extract start and finish times
    start = [i.left for i in I]
    finish = [i.right for i in I]

    p = []
    for j in range(len(I)):
        # rightmost interval f_i <= s_j
        i = bisect.bisect_right(finish, start[j]) - 1
        p.append(i)

    return p