You are viewing a single comment's thread. Return to all comments →
my approach is also similar but i am getting segmentation fault in some test cases. please tell the problem.
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 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 →
my approach is also similar but i am getting segmentation fault in some test cases. please tell the problem.
long arrayManipulation(int n, vector> queries) {