Untitled
unknown
plain_text
2 years ago
832 B
9
Indexable
#include <iostream>
#include <string>
using namespace std;
bool isSubsequence(string s, string t) {
int flag = 0;
int i = 0,j=0,count=0;
const char* copy = t.data();
for (; i < s.length(); i++) {
int k = t.length();
char token = s[i];
// int flag;
for (j = count; j < k; j++) {
if (*(copy+j) == token){
flag++;
count++;
break;
}
}
// count++;
}
if (flag == i) {
return true;
} else return false;
}
int main() {
bool output = isSubsequence("acb", "ahbgdc");
if (output == true) cout << "true";
else cout << "false";
return 0;
}
Editor is loading...