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.
functionarrayManipulation(n,queries){// Write your code hereconstarr=newArray(n).fill(0);letmax=0;for(leti=0;i<queries.length;i++){const[a,b,k]=queries[i];// -1 because arrays are indexed 0, but a & b constraints 1<=a<=b<=nfor(letj=a-1;j<=b-1;j++){arr[j]+=k;max=Math.max(arr[j],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 →