You are viewing a single comment's thread. Return to all comments →
Can someone help to optimize the below code ? Time limit exceeding for only 7 testcases. Rest all passed
function arrayManipulation(n, queries) { let obj = {}; let max = 0; for (let arr of queries) { for (let i = arr[0] - 1; i < arr[1]; i++) { obj[i] = obj[i] ? (obj[i] += arr[2]) : arr[2]; if (obj[i] > max) max = obj[i]; } } 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 →
Can someone help to optimize the below code ? Time limit exceeding for only 7 testcases. Rest all passed