You are viewing a single comment's thread. Return to all comments →
C++ solution:
long arrayManipulation(int n, vector<vector<int>> queries) { vector<long> arr(n+2); for (const auto& q : queries) { int a=q[0], b=q[1], k=q[2]; arr[a] += k; arr[b+1] -= k; } partial_sum(begin(arr), end(arr), begin(arr)); return *max_element(begin(arr), end(arr)); }
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 →
C++ solution: