Range Update

Revision en2, by Qualified, 2020-08-17 04:35:27

You are given a number $$$n$$$ and a number $$$m$$$ and an array $$$a$$$ of $$$n$$$ numbers and 1 type of query. All of the numbers below are 0 based indexing.

1) Given 3 numbers, $$$l$$$, $$$r$$$ , $$$x$$$. You add all the numbers from l to r(inclusive) by x. For example if the initial array was {5, 4, 3, 9, 2} and the query was {0, 2, 5} then the array would become {10, 9, 8, 9, 2}. Also, print the array.

After each query, store the new array as array $$$a$$$.

At the end print the array a.

m describes the number of queries being asked.

Example:

4 3
1 9 2 2
2 2 3
0 3 5
2
Output:

10
6 14 10 7

Should be less that $$$O(n^{2})$$$

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English Qualified 2020-08-17 05:12:09 4 Tiny change: ' that $O(n^{2})$' -> ' that $O(n)$'
en2 English Qualified 2020-08-17 04:35:27 16
en1 English Qualified 2020-08-17 04:35:02 638 Initial revision (published)