We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
longarrayManipulation(intn,vector<vector<int>>queries){// the boundary extended by 2 since 0 th position is not used.vector<longint>map_vector(n+2,0);longintmax_value=0,moving_sum=0;for(autorows:queries){map_vector[rows[0]]+=rows[2];map_vector[rows[1]+1]-=rows[2];}for(autoiter:map_vector){moving_sum+=iter;if(max_value<moving_sum)max_value=moving_sum;}returnmax_value;}
Cookie support is required to access HackerRank
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 →
thanks for the logic: