Running Sum of an Array
The Running Sum of an Array problem involves calculating the cumulative sum of elements in an array.
Given an integer array arr[] of size n, return an array where each element at index i represents the sum of all elements from index 0 to i.
The running sum at index i is calculated as:
runningSum[i] = arr[0] + arr[1] + ... + arr[i]
This problem helps in understanding Prefix Sum, cumulative computations, and efficient array traversal.
Example 1
Input
arr[] = [1,2,3,4]
Output
[1,3,6,10]
Explanation
Example 2
Input
arr[] = [5,1,2,7]
Output
[5,6,8,15]
Explanation
Constraints
Hints:
Hint 1
Author & Technical Reviewer
Technically reviewed by: ExamAdda Technical Review Team
Technical Reviewers, ExamAdda
Software engineers at ExamAdda who check every article's definitions, complexity claims and code examples before and after publishing.
Published
Jul 2, 2026
Last updated
Jul 31, 2026
Content Verification Methodology
Definitions and complexity claims were checked against authoritative computer-science references. Code examples were compiled and tested with standard, boundary and edge-case inputs.
Expected Output