Given an array nums, define its running sum as runningSum[i] = sum(nums[0]…nums[i]). Return the running sum of nums.
nums = [1,2,3,4][1,3,6,10]nums[i] += nums[i-1]At each step, nums[i-1] already holds the sum of elements 0..i-1. Adding it to nums[i] extends the running total by one element. This builds the prefix sum left to right in a single pass with no extra array needed.