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){Map<Integer,Long>sum=newTreeMap<>();// order by keyfor(List<Integer>list:queries){inta=list.get(0);intb=list.get(1);longk=list.get(2);sum.put(a,sum.getOrDefault(a,0L)+k);sum.put(b+1,sum.getOrDefault(b+1,0L)-k);}longmax=0L;longcurrent=0L;for(longvalue:sum.values()){current+=value;max=Math.max(max,current);}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