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.
Same idea in java. Thank you for posting this by the way , helped immensely!
static long arrayManipulation(int n, int[][] queries) {
long[] diff = new long[n+2];
for(int[] query : queries){
diff[query[0]]+=query[2]; //a,b,k
diff[query[1]+1]-=query[2];
}
long max =0;
long current=0;
for(long i : diff){
current+=i;
if (current > max )
max = current;
}
return max;
}
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 →
Same idea in java. Thank you for posting this by the way , helped immensely!