Skip to content

Instantly share code, notes, and snippets.

@cli248
Last active December 29, 2015 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cli248/7686764 to your computer and use it in GitHub Desktop.
Save cli248/7686764 to your computer and use it in GitHub Desktop.
check if string A is a sub sequence of string B
/*
* Credits: http://stackoverflow.com/questions/8599374/sub-sequence-occurrence-in-a-string
*/
bool checkSubSequence(string A, string B) {
int pos = -1;
bool ok = true;
for (int i=0; i!=A.size() && ok; i++)
ok = (pos = B.find(A[i], pos+1)) != string::npos;
return ok;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment