You are viewing a single comment's thread. Return to all comments →
Added some ES6 syntax suger...
const arrayManipulation2 = (n, queries) => { const arr = new Array(n).fill(0); let max = 0; for (let i = queries.length - 1; i >= 0; i--) { const [a, b, k] = queries[i]; arr[a - 1] += k; if (b < arr.length) { arr[b] -= k; } } for (let j = 1; j < n; j++) { arr[j] += arr[j - 1]; } for (let k = arr.length - 1; k >= 0; k--) { max = Math.max(max, arr[k]); } 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 →
Added some ES6 syntax suger...