Question bank › Prefix Sum
Dsa Prefix Sum Medium

Monthly Revenue Tracking

You are responsible for tracking the monthly revenue changes of a retail store over a year. Given a list of monthly revenue changes, calculate the total revenue between a specified month range. The store starts with a fixed revenue of 0 at month 1. Input format: - The first line contains an integer N (1 ≤ N ≤ 12). - The second line contains N integers representing monthly revenue changes. - The third line contains two integers A and B (1 ≤ A ≤ B ≤ N). Output format: - An integer representing the total revenue from month A to month B. Example: Input: 6 200 -150 300 -100 50 200 2 5 Output: 300

Key concepts

prefix_sumrange_sum_querycumulative_sum

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.