Skip to content

Commit 2dae791

Browse files
committed
392
1 parent a13455c commit 2dae791

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

392.cpp

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
class Solution {
2+
public:
3+
bool isSubsequence(string s, string t) {
4+
5+
int n=s.length();
6+
int m =t.length();
7+
int i,j;
8+
for(i=0,j=0;i<n && j<m;)
9+
{
10+
if(s[i]!=t[j])
11+
{
12+
// i++;
13+
j++;
14+
}
15+
else if(s[i]==t[j])
16+
{
17+
j++;
18+
i++;
19+
}
20+
21+
}
22+
23+
if(i==n)
24+
{
25+
return 1;
26+
}
27+
28+
29+
return 0;
30+
31+
}
32+
};

0 commit comments

Comments
 (0)