Question bank › Prefix Sum
Dsa Prefix Sum Easy

Store Revenue Calculation

You are tasked with calculating total store revenue over a series of days. You will receive a list of daily revenues for a week. Given a range of days, your goal is to determine the total revenue generated during that range. The input first consists of an integer n, the number of days followed by n integers representing daily revenues. Next, you receive a single query defined by two integers, start and end, denoting the days (0-indexed) to calculate cumulative revenue. Print the total revenue from 'start' to 'end' (inclusive). For example: Input: 7 100 200 300 400 500 600 700 2 5 Output: 2000 This output corresponds to the sum of revenues from day 2 to day 5 (300 + 400 + 500 + 600).

Key concepts

prefix_sumarraycumulative

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.