You are viewing a single comment's thread. Return to all comments →
O(1) auxiliary space !!! wtf dude What about that "N" sized array you are creating dynamically???
I don't think this question should need more than O(m) complexity (either space or time wise) Here's my approach:-
long arrayManipulation(int n, vector> queries) {
map<int, long> m; for(vector<int> i:queries) { int a=i[0], b=i[1]; m[a]+=i[2]; m[b+1]-=i[2]; } long val=0, ans=0; for(pair<int, long> p : m) { val+=p.second; ans=max(ans, val); } 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 →
O(1) auxiliary space !!! wtf dude What about that "N" sized array you are creating dynamically???
I don't think this question should need more than O(m) complexity (either space or time wise) Here's my approach:-
long arrayManipulation(int n, vector> queries) {
}