Question bank › Prefix Sum
Dsa Prefix Sum Hard

Range Sum Query with Updates

You are given an array of integers. Implement a function to handle two types of operations: 1) Calculate the sum of elements between indices L and R (inclusive). 2) Update the value at a specific index to a new value. Input starts with an integer N (size of the array) followed by N integers. The next lines contain queries of format 'sum L R' or 'update index value'. Output the results of the sum queries, one per line. Example: Input: 5 1 2 3 4 5 sum 1 3 update 2 10 sum 1 4 Output: 6 17

Key concepts

prefix_sumarray_manipulation

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.