• + 0 comments

    I replaced this part of your code :

    max = x = 0 for i in list: x=x+i; if(max

    by this:

    max=list1[0] for j in range(1,n): list1[j]=list1[j]+list1[j-1] if max

    here list1 is prefix sum array why did my code failed few test cases? here's my entire code : def arrayManipulation(n, queries): list1=[0]*(n+1)

    for i in range(len(queries)):
        list1[queries[i][0]-1]+=queries[i][2]
        list1[queries[i][1]]+=-queries[i][2]
    """prefix sum"""
    max=list1[0]
    for j in range(1,n):
        list1[j]=list1[j]+list1[j-1]
        if max<list1[j]:
            max=list1[j]
    return(max)
    
    
    
    
    
    
        if max<list1[j]:
            max=list1[j]