🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Prefix Sums and Difference Arrays: all 13 questions

Quiz: Prefix Sums and Difference Arrays · Question 11 of 13

Why is the difference array one cell longer than the result?

Why is the difference array one cell longer than the result?

  1. A.To store the total sum at the end
  2. B.Because Python lists start at 1
  3. C.An update that ends at the last index writes d[r + 1], which is one past the end
  4. D.To keep a copy of the original array
Answer & explanation

Correct answer: An update that ends at the last index writes d[r + 1], which is one past the end

With r = n − 1, d[r + 1] = d[n] must exist, even though it is never added into the result.

Can you get the rest right without peeking?

Take the timed Quiz: Prefix Sums and Difference Arrays quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →