You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Problem Link : https://practice.geeksforgeeks.org/problems/max-value-after-m-range-operation4300/1/?category[]=prefix-sum&category[]=prefix-sum&difficulty[]=-1&page=1&sortBy=submissions&query=category[]prefix-sumdifficulty[]-1page1sortBysubmissionscategory[]prefix-sum
int findMax(int n, int m, int a[], int b[], int k[])
{
// Your code goes here
vector<int> arr(n);
for(int i = 0; i < m; i++){
arr[a[i]] += k[i]; // We want effect of this element from this index so we add that
if(b[i] < n-1)
arr[b[i]+1] -= k[i]; // We want to remove effect of this element from next index of it so we substract that