2023每日刷题(五十七) Leetcode—1480.一维数组的动态和 实现代码 /*** Note: The returned array must be malloced, assume caller calls free().*/int* runningSum(int* nums, int numsSize, int* returnSize){*returnSize = num
class Solution {public:vector<int> runningSum(vector<int>& nums) {vector<int> runningSum;int sum = 0;int len = nums.size();for(int i = 0; i < len; i++){sum = sum + nums[i];runningSum.push_back(sum)