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[]res=newlong[n+2];longmax=0;for(inti=0;i<queries.size();i++){inta=queries.get(i).get(0);intb=queries.get(i).get(1);intk=queries.get(i).get(2);res[a]=res[a]+k;res[b+1]=res[b+1]-k;}for(inti=1;i<=n;i++){res[i]=res[i]+res[i-1];max=Math.max(res[i],max);}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 →