public int[] getModifiedArray(int length, int[][] updates) {
int[] nums = new int[length];
int k = updates.length;
for(int i = 0; i < k; i++){
int start = updates[i][0];
int end = updates[i][1];
int inc = updates[i][2];
for(int j = start; j <= end; j++){
nums[j] += inc;
}
}
return nums;
}
Java Straightforward solution


@steve.j.sun Did you really manage to get this accepted? Your solution is naive
O(n*k)
time complex. Ideally it should time out.
