-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1480-Running-sum-of-1d-array.cs
More file actions
40 lines (33 loc) · 931 Bytes
/
1480-Running-sum-of-1d-array.cs
File metadata and controls
40 lines (33 loc) · 931 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Collections.Generic;
using System.Text;
namespace Solution._1480.Running_sum_of_1d_array
{
public class _1480_Running_sum_of_1d_array
{
public int[] RunningSum(int[] nums)
{
for (int i = 1; i < nums.Length; i++)
nums[i] = nums[i] + nums[i - 1];
return nums;
}
/// <summary>
/// The first thought
/// </summary>
/// <param name="nums"></param>
/// <returns></returns>
//public int[] RunningSum(int[] nums)
//{
// int i, j, tmp;
// int[] result = new int[nums.Length];
// for (i = 0; i < nums.Length; i++)
// {
// tmp = 0;
// for (j = 0; j <= i; j++)
// tmp = tmp + nums[j];
// result[i] = tmp;
// }
// return result;
//}
}
}