You are viewing a single comment's thread. Return to all 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; }
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;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Array Manipulation
You are viewing a single comment's thread. Return to all comments →
can you please check problem in my code too. it is giving segmentation fault in some of the test cases.