You are viewing a single comment's thread. Return to all comments →
Here's a solution in C#
public static long arrayManipulation(int n, List<List<int>> queries) { long[] arr = new long[n]; long sum = 0; long max = 0; for(int i=0; i < queries.Count; i++){ int a = queries[i][0] - 1; int b = queries[i][1] - 1; int k = queries[i][2]; arr[a] += k; if(b+1 < n) arr[b+1] -= k; } for (int j = 0; j < arr.Length; j++){ sum += arr[j]; max = Math.Max(max,sum); } 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 →
Here's a solution in C#