File tree Expand file tree Collapse file tree 2 files changed +44
-2
lines changed
LeetCodeSolutions/TwoPointers Expand file tree Collapse file tree 2 files changed +44
-2
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change 2
2
3
3
![ ] ( https://img.shields.io/badge/Neovim-57A143.svg?logo=Neovim& ; logoColor=white )
4
4
![ ] ( https://img.shields.io/badge/Visual_Studio_Code-0078D4?logo=visual%20studio%20code& ; logoColor=white )
5
- ![ ] ( https://img.shields.io/badge/Progress-0 %2F150-0078D4 )
5
+ ![ ] ( https://img.shields.io/badge/Progress-25 %2F150-0078D4 )
6
6
7
7
This repository contains solutions to the Leetcode Top Interview 150 problems.
8
8
@@ -70,7 +70,7 @@ The Top Interview 150 collection on Leetcode is a curated set of 150 interview q
70
70
| 24 | Text Justification | Hard | |
71
71
| <br > Two Pointers<br > | | | |
72
72
| 25 | Valid Palindrome | Easy | ✅ |
73
- | 26 | Is Subsequence | Easy | |
73
+ | 26 | Is Subsequence | Easy | ✅ |
74
74
| 27 | Two Sum II - Input Array Is Sorted | Medium | |
75
75
| 28 | Container With Most Water | Medium | |
76
76
| 29 | 3Sum | Medium | |
You can’t perform that action at this time.
0 commit comments