You are viewing a single comment's thread. Return to all comments →
Thank you. This is clear.
You could also find the max using:
def arrayManipulation(n, queries):
# initialise list
arr =  * (n + 1)
for a, b, k in queries:
arr[a - 1] += k
arr[b] -= k
# accumulate values
However, I have not understood the theory behind the difference array algorithm, why it works the way it works and how to derive it.