You are viewing a single comment's thread. Return to all comments →
Cool Honestly, I hardly figure that out. At least not in a single day.
This is my JS version:
function arrayManipulation(n, queries) { let arr = [], max = 0, x = 0 arr.length = n+1 arr.fill(0) for (let i = 0; i < queries.length; i++) { const a = queries[i][0] const b = queries[i][1] const k = queries[i][2] arr[a] +=k if ((b+1)<=n) arr[b+1]-=k; } for (let i = 1; i <= n; i++ ) { x = x + arr[i] if (x > max) max = x } 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 →
Cool Honestly, I hardly figure that out. At least not in a single day.
This is my JS version: