Dsa
Prefix Sum
Warm-up
Market Growth Analysis
You are given a list of daily profits (or losses) of a company over a week. Your task is to compute the cumulative profit by the end of the week. The cumulative profit for day `i` is the sum of profits from day 1 to day `i`.
Input:
- A single line containing 7 integers which may be positive (profit) or negative (loss).
Output:
- A single line containing 7 integers, where each integer represents the cumulative profit by the end of that day.
Example:
Input:
10 -5 3 0 7 -1 4
Output:
10 5 8 8 15 14 18
Key concepts
prefix_sumarray_processing
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