Closed championballer closed 4 years ago
@championballer var arr = []; var max = 0; for (let l = 0; l < n; l++) { arr[l] = 0; } for (let i = 0; i < queries.length; i++) { arr[queries[i][0]-1] += queries[i][2]; if (queries[i][1] < arr.length) { arr[queries[i][1]] -= queries[i][2]; } } for (let j = 1; j < n; j++) { arr[j] += arr[j-1]; } for (let k = 0; k < arr.length; k++) { max = Math.max(max, arr[k]); } return max;
Looks good. You want to create a PR for the same? Just change all var to let
Sir @championballer now u can close it.
The following code is giving a runtime error for the Array Manipulation, but passing for 75% test cases. Can anyone proficient in JS help debug this. Thanks.