You are viewing a single comment's thread. Return to all comments →
TypeScript
function arrayManipulation(n: number, queries: number[][]): number { const result = new Array(n + 1).fill(0); for (const [start, end, value] of queries) { result[start - 1] += value; if (end < n) { result[end] -= value; } } let max = 0; let currentSum = 0; for (let i = 0; i < n; ++i) { currentSum += result[i]; max = Math.max(max, currentSum); } 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 →
TypeScript