• + 0 comments

    Your solution is brilliant! Here is the same code in python :-

    def arrayManipulation(n, queries):

    temp=[0]*(n+1)
    
    for x in queries:
    
        temp[x[0]] += x[2]
        if((x[1]+1)<=n):
            temp[x[1]+1]-=x[2]
        print(temp)
    
    maxl =0
    x=0
    for i in range(n+1):
        x=x+temp[i];
        if(maxl<x):
            maxl=x
    
    return maxl