← Return

Array ManipulationHard

Starting with a 1-indexed array of zeros and a list of operations, for each operation add a value to each array element between two given indices, inclusive. Once all operations have been performed, return the maximum value in the array.

Example

\(n = 10\)

\(queries = [(1, 5, 3), (4, 8, 7), (6, 9, 1)]\)

Queries are interpreted as follows:

    a b k
    1 5 3
    4 8 7
    6 9 1

Add the values of \(k\) between the indices \(a\) and \(b\):

The largest value is \(10\) after all operations are performed.