Last active
December 29, 2015 14:49
-
-
Save cli248/7686764 to your computer and use it in GitHub Desktop.
check if string A is a sub sequence of string B
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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