Question bank › Prefix Sum
Dsa Prefix Sum Easy

Sprint Progress Tracker

You are developing a fitness tracking application. Users log their running progress each day, and you need to answer queries regarding their total mileage over specific days. The input will consist of an integer n representing the number of days followed by n integers indicating the mileage for each day. You will have q queries, each consisting of two integers which define the start and end day (inclusive). For each query, output the total mileage run between those days. For example: Input: 5 3 4 5 6 7 2 1 3 0 4 Output: 15 25 The first query asks for the mileage from day 1 to day 3 (4 + 5 + 6), resulting in 15, whereas the second sums all daily mileage, resulting in 25.

Key concepts

prefix_sumrange_sumquery

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 Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.