Dsa
Prefix Sum
Warm-up
Weekly Caloric Intake
You are tracking your caloric intake over a week. Write a program that calculates your total intake by the end of each day, given a list of daily caloric values. The program should output the cumulative calories consumed each day.
Input format:
- A single line with 7 integers representing daily caloric intake.
Output format:
- A single line with cumulative calories up to each day, separated by spaces.
Example:
Input:
2000 1800 2200 2500 2100 1900 2300
Output:
2000 3800 6000 8500 10600 12500 14800
Key concepts
prefix_sumcumulative_sumnutrition
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