Data Structures19 sections · 729 units
Open in Course

Problem - Range Addition

Apply difference arrays

You have an array of length nn initialized to zeros. You're given kk update operations. Each operation adds a value valval to all elements from index startstart to endend inclusive.

Return the final array. You're solving the textbook difference array problem. With kk updates and length nn, naive approach is O(kn)O(kn). With difference arrays, it's O(k+n)O(k + n). Read the problem carefully.