def range_addition(n, updates):
    """

    LeetCode 370: Range Addition
    Assume you have a list `[0] * n` and are given k update operations.
    Each operation is represented as a triplet `[start_index, end_index, increment]`,
    which adds increment to each element of subarray A[start_index ... end_index] (start_index and end_index inclusive).
    Return the modified array after all k operations were executed.
    Examples:
        1. n = 5, updates = [(1,  3,  2), (2,  4,  3), (0,  2, -2)]. return: [-2, 0, 3, 5, 3]
    :param n: length of list
    :param updates: [(start_index, end_index, increment), ...]
    :return:
    """
    res = [0] * (n + 1)
    for si, ei, inc in updates:
        res[si] += inc
        res[ei + 1] -= inc
    for i in range(1, n + 1):
        res[i] += res[i - 1]
    return res[:-1]