Skip to content

Commit 16097e3

Browse files
authored
22 september 2023
1 parent ef199bb commit 16097e3

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

392. Is Subsequence

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Runtime 0 ms
2+
Beats 100%
3+
4+
5+
Memory 40.2 MB
6+
Beats 80.22%
7+
8+
9+
class Solution {
10+
public boolean isSubsequence(String s, String t) {
11+
char[]T = t.toCharArray();
12+
char[]S = s.toCharArray();
13+
int m = T.length, n = S.length;
14+
15+
if(n==0)
16+
return true;
17+
18+
int s_ptr=0;
19+
for(int i=0;i<m;i++){
20+
if(S[s_ptr]==T[i])
21+
s_ptr++;
22+
if(s_ptr==n)
23+
return true;
24+
}
25+
26+
return false;
27+
28+
}
29+
}

0 commit comments

Comments
 (0)