Question bank › Prefix Sum
Dsa Prefix Sum Warm-up

Daily Temperature Gains

You are given a list of daily temperature gains for a week, where each gain represents how much the temperature increased from the previous day. Write a program that calculates the cumulative temperature gain at the end of each day. The program should output the cumulative gains as a list, where each element represents the cumulative gain from day 1 up to that day. Input format: - A single line containing 7 integers representing the daily temperature gains. Output format: - A single line containing the cumulative temperature gains, separated by spaces. Example: Input: 5 3 0 2 7 1 4 Output: 5 8 8 10 17 18 22

Key concepts

prefix_sumarray_manipulationcumulative_sum

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 InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.