Dsa
Prefix Sum
Easy
Bank Account Balance Tracker
You are building a bank application that tracks a user's account balance over time. Given a series of transactions (positive for deposits, negative for withdrawals), calculate the cumulative balance at the end of each transaction starting from an initial balance of 1000.
Input format:
- The first line contains an integer, T (1 <= T <= 1000), representing the number of transactions.
- The second line contains T space-separated integers representing the transaction amounts.
Output format:
- Output T space-separated integers representing the cumulative balance after each transaction.
Example:
Input:
5
200 -50 100 -300 50
Output:
1200 1150 1250 950 1000
Key concepts
prefix_sumcumulative_sums
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