• + 3 comments

    guys, my code is producing a segmentation fault using the following funciton. Please help me, not sure what i'm doing wrong.

    ` long arrayManipulation(long n, vector> queries, long m) {

    long i, j, result[n], max = INT_MIN;
    for(i = 0; i < n; i++)
    {
        result[i] = 0;
    }
    for(i = 0; i < m; i++)
    {
        for(j = queries[i][0] - 1; j <= queries[i][1] - 1; j++)
        {
            //result[j] = 0;
            result[j] = result[j] + queries[i][2];
            if(result[j] > max)
            {
                max = result[j];
            }
        }
    }
    return max;
    

    } `