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.
publicstaticlongarrayManipulation(intn,List<List<Integer>>queries){// Write your code herelong[]tmp=newlong[n];longmax=0,tmpSum=0;inta,b,k;for(List<Integer>query:queries){a=query.get(0);b=query.get(1);k=query.get(2);tmp[a-1]+=k;if(b<n){tmp[b]-=k;}}for(inti=0;i<n;i++){tmpSum+=tmp[i];max=Math.max(max,tmpSum);}returnmax;}
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 →
java: