is-subsequence
1.0.0
Is Subsequence
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1
#include <bits/stdc++.h>
2
3
using namespace
std;
4
5
class
Solution
6
{
7
public
:
8
bool
isSubsequence
(
string
s,
string
t)
9
{
10
if
((
int
)s.size() == 0)
11
return
true
;
12
13
int
index = 0;
14
for
(
char
c: t)
15
{
16
if
(c == s[index])
17
{
18
index++;
19
if
(index == (
int
)s.size())
20
return
true
;
21
}
22
}
23
return
false
;
24
}
25
};
26
27
int
main
()
28
{
29
cout <<
"is s a subsequence of t: "
<<
Solution
().
isSubsequence
(
"abc"
,
"ahbgdc"
) << endl;
30
return
0;
31
}
Solution
Definition
main.cpp:6
Solution::isSubsequence
bool isSubsequence(string s, string t)
Definition
main.cpp:8
main
int main()
Definition
main.cpp:27
main.cpp
Generated by
1.9.8