• + 0 comments

    can you please check problem in my code too. it is giving segmentation fault in some of the test cases.

    long arrayManipulation(int n, vector> queries) { long a[n]={0};

    for(int i=0;i<queries.size();i++)
    {
        a[queries[i][0]-1]+=queries[i][2];
        if(queries[i][1]<n)
        a[queries[i][1]]-=queries[i][2];
    }
    long ans=a[0];
    for(int i=1;i<n;i++)
    {
        a[i]+=a[i-1];
        ans=max(ans,a[i]);
    }
    return ans;
    

    }