Skip to content

Commit d9e5593

Browse files
committed
https://leetcode.com/problems/is-subsequence
1 parent 407ba75 commit d9e5593

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
namespace LeetCodeSolutions.TwoPointers;
3+
4+
public class IsSubsequenceSolution
5+
{
6+
public bool IsSubsequence(string s, string t)
7+
{
8+
int i = 0;
9+
int j = 0;
10+
11+
while (i < s.Length && j < t.Length)
12+
{
13+
if (s[i] == t[j])
14+
{
15+
i++;
16+
}
17+
j++;
18+
}
19+
20+
return i == s.Length;
21+
}
22+
23+
[Test(Description = "https://leetcode.com/problems/is-subsequence/")]
24+
[Category("Easy")]
25+
[Category("LeetCode")]
26+
[Category("Is Subsequence")]
27+
[TestCaseSource(nameof(Input))]
28+
[Category("TwoPointers")]
29+
[Category("TopInterview")]
30+
public void Test1((bool Output, (string, string) Input) item)
31+
{
32+
var response = IsSubsequence(item.Input.Item1, item.Input.Item2);
33+
Assert.That(response, Is.True);
34+
}
35+
36+
public static IEnumerable<(bool Output, (string, string) Input)> Input =>
37+
new List<(bool Output, (string, string) Input)>()
38+
{
39+
40+
(true, ("abc", "ahbgdc")),
41+
};
42+
}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
![](https://img.shields.io/badge/Neovim-57A143.svg?logo=Neovim&amp;logoColor=white)
44
![](https://img.shields.io/badge/Visual_Studio_Code-0078D4?logo=visual%20studio%20code&amp;logoColor=white)
5-
![](https://img.shields.io/badge/Progress-0%2F150-0078D4)
5+
![](https://img.shields.io/badge/Progress-25%2F150-0078D4)
66

77
This repository contains solutions to the Leetcode Top Interview 150 problems.
88

@@ -70,7 +70,7 @@ The Top Interview 150 collection on Leetcode is a curated set of 150 interview q
7070
| 24 | Text Justification | Hard | |
7171
| <br> Two Pointers<br> | | | |
7272
| 25 | Valid Palindrome | Easy ||
73-
| 26 | Is Subsequence | Easy | |
73+
| 26 | Is Subsequence | Easy | |
7474
| 27 | Two Sum II - Input Array Is Sorted | Medium | |
7575
| 28 | Container With Most Water | Medium | |
7676
| 29 | 3Sum | Medium | |

0 commit comments

Comments
 (0)