Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
832 B
3
Indexable
Never
#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;
}