Back to problems

Range Updates Using Difference Array (Template Problem)

Algorithm · Google · Easy

Problem (Incomplete; abstracted from description) You have an array containing n elements. It may begin with all entries equal to zero, or it may be supplied with initial values. You must process q range-update operations. An operation adds delta to every element whose index lies inclusively between l and r: For every i satisfying l <= i <= r, perform arr[i] += delta. The indexing convention is unspecified: the original problem may use either zero-based or one-based indices.…

Checking your access…