You are viewing a single comment's thread. Return to all comments →
simpler in es6:
function arrayManipulation(n, queries) { let arr = new Array(2*n).fill(0); let max = 0;
queries.forEach((item) => { arr[item[0]] += item[2]; arr[item[1] + 1] -= item[2]; }); arr.reduce((prev, curr, idx) => { const sum = prev + curr; if (sum > max) { max = sum; } return sum; }) return max;
}
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 →
simpler in es6:
function arrayManipulation(n, queries) { let arr = new Array(2*n).fill(0); let max = 0;
}