Question DSA-ARR-0051
MediumWith a difference array, how fast can you add a value to every element in a range [l, r]?
- A.
O(log n) per update
- B.
O(n) per update
- C.
Sign up free to see the answer and a step-by-step explanation.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Arrays question
With a difference array, how fast can you add a value to every element in a range [l, r]?
O(log n) per update
O(n) per update
Sign up free to see the answer and a step-by-step explanation.
O(1) per update, with an O(n) pass at the end to get the final values
O(n²)