Running Totals

L3 Easy Sliding Window
Concept
The running sum is the simplest prefix computation: each new element carries the total so far. Prefix structures make range queries nearly free.
Given an array nums, return an array where the element at each position is the sum of all elements up to and including that position.
Examples
▸ nums = [1, 2, 3, 4]
→ [1, 3, 6, 10]
▸ nums = [1, 1, 1, 1, 1]
→ [1, 2, 3, 4, 5]
▸ nums = [3, 1, 2]
→ [3, 4, 6]
Progressive Hints
Hint 1 · Nudge
Each answer reuses the one before it plus the current element.
Hint 2 · Plan
Walk the array building a result where the value at each position is the previous position's value plus the current element. The first value stays unchanged.
Hint 3 · Approach
result[0] = nums[0]. For i starting at 1: result[i] = result[i - 1] + nums[i]. Return result.
Output
// Run your code to see the output here.