Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i]).
Return the running sum of nums.
Example 1:
1 | Input: nums = [1,2,3,4] |
Example 2:
1 | Input: nums = [1,1,1,1,1] |
Example 3:
1 | Input: nums = [3,1,2,10,1] |
這篇要求array值某位值一直不斷加總前幾位的值,那就給個迴圈,尋訪過程不斷加前一位,學到迴圈用range(len())取得計數。
如果你覺得這篇文章很棒,請你不吝點讚 (゚∀゚)