Skip to content
Squarebrackets Private Limited
Squarebrackets
Courses
Browse
Explore
Services
Learning
Prep
Code&Run
Whiteboard
LMS
Problems

Running Sum of 1D Array

Easy1 pt
ArrayPrefix Sum
PrerequisitesArray, Prefix Sum
Given an array nums, return its running (prefix) sum, where runningSum[i] = sum(nums[0..i]). Input: space-separated integers. Output: space-separated running sums.
Example 1
Input
1 2 3 4
Output
1 3 6 10
Explanation
For the given input, the program prints exactly this output.
Example 2
Input
3 1 2 10 1
Output
3 4 6 16 17
Explanation
A second case — verify your logic handles it too.
Hints
Video
8 lines
Input (stdin)
Expected output · optional
Run checks your code against every example, one by one — all must pass. Type your own input above to run that instead (Run compares it to the expected output if you set one). The full suite is checked on Submit — a failing case reveals its input & expected output.