Dsa
Prefix Sum
Warm-up
Weekly Expense Tracker
You are tracking weekly expenses for a household. Each day's expense can be positive (spending) or negative (income). Your task is to calculate the total expense by the end of each day of the week.
Input:
- A single line containing 7 integers representing daily expenses.
Output:
- A single line containing 7 integers, with each integer representing the total expense by the end of that day.
Example:
Input:
100 -50 200 -100 300 50 -150
Output:
100 50 250 150 450 500 350
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