bool isSubsequence(std::string const& self, std::string const& other, std::string::size_type other_n, bool caseInsensitive) { return caseInsensitive ? isSubsequence(boost::algorithm::to_lower_copy(self), boost::algorithm::to_lower_copy(other), other_n) : isSubsequence(self, other, other_n) ; }
int main(void) { int T,isOk; char *s1,*s2; scanf("%d",&T); s1=(char*)malloc(sizeof(char)); s2=(char*)malloc(sizeof(char)); while(T--) { scanf("%s %s",s1,s2); isOk = (isSubsequence(s1,s2) || isSubsequence(s2,s1)); if(isOk) { printf("YES\n"); } else { printf("NO\n"); } } return 0; }
int main(int argc, const char * argv[]) { std::string a = argv[1]; std::string b = argv[2]; std::cout << "look for subsequences in " << a << ", " << b << "\n"; std::list<char> list_a = putIntoList(a); std::list<char> list_b = putIntoList(b); if ( isSubsequence(list_a, list_b) ) std::cout << "B is a subsequence of A\n"; else if ( isSubsequence(list_b, list_a) ) std::cout << "A is a subsequence of B\n"; else std::cout << "They are not subsequences of eachother\n"; return 0; }
bool isSubsequence(std::string const& self, std::string const& other, bool caseInsensitive) { return isSubsequence(self, other, other.length(), caseInsensitive); }
bool isSubsequence(std::string const& self, std::string const& other) { return isSubsequence(self, other, other.length()); }