Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

Range update and query on a non-standard array

$
0
0

I have an array arr[] of size n (<=10^5) and I have to do range update and query over it.

Problem is, the update has to happen according to an update multiplier array mult[]={c_0,c_1,c_2, ...} such that if I add k on arr[a] to arr[b], then

arr[a] = arr[a]+k*c_a
arr[a+1] = arr[a+1] + k*c_(a+1)
.
.
.
arr[b] = arr[b] + k*c_b

I have to do lazy update. What will the update function be like?


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>