• + 0 comments

    A bit less efficient, but more readable

    def arrayManipulation(n, queries):
        a = [0] * (n + 1)
        for q in queries:
            a[q[0] - 1] += q[2]
            a[q[1]] -= q[2]
    
        for i in range(1, len(a)):
            a[i] += a[i-1]
    
        return max(a)