Skip to content

Commit a580d35

Browse files
authored
Merge pull request #1057 from sulaimanhayek/main
Create 392-is-subsequence.cs && 1480-Running-Sum-of-1d-Array.cs
2 parents 678a8a7 + de955fb commit a580d35

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

Diff for: csharp/1480-Running-Sum-Of-1D-Array.cs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
public class Solution
2+
{
3+
public int[] RunningSum(int[] nums)
4+
{
5+
for (int i = 1; i < nums.Length; i++)
6+
{
7+
nums[i] = nums[i - 1] + nums[i];
8+
}
9+
return nums;
10+
}
11+
}

Diff for: csharp/392-Is-Subsequence.cs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
public class Solution
2+
{
3+
public bool IsSubsequence(string s, string t)
4+
{
5+
int i = 0;
6+
int j = 0;
7+
while ((i < s.Length) && (j < t.Length))
8+
{
9+
if (s[i] == t[j])
10+
{
11+
i += 1;
12+
}
13+
j += 1;
14+
15+
}
16+
if (i == s.Length)
17+
{
18+
return true;
19+
}
20+
else return false;
21+
}
22+
}

0 commit comments

Comments
 (0)