🎙 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 6 of 13

m range updates on an array of n elements with a difference array cost:

m range updates on an array of n elements with a difference array cost:

  1. A.O(n · m)
  2. B.O(n + m)
  3. C.O(m log n)
  4. D.O(n²)
Answer & explanation

Correct answer: O(n + m)

Each update is two O(1) writes; one O(n) running sum at the end builds the final array.

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 →