PROBLEM LINK:
PRACTICE
Editorialist: Avishake Maji
DIFFICULTY:
EASY
PREREQUISITES:
String
PROBLEM:
Chef’s friend Rahul gave him a piece of paper. On this paper there are few strings(string A) and beside each string another string(String B) is given. Chef needs to find whether he can convert string A to string B after zero or more deletions. But there is a condition chef can delete either the first or the last character. Chef is busy and so he needs your help.
Input:
t: Number of test cases
sa: String A
sb: String B
Output:
Print ‘YES’ if String A can be converted to String B otherwise print ‘NO’
Constraints:
1<=t<=1000
1<=length(sa),length(sb)<=20
Sample Input:
2
abcdefgh
cde
hello
hey
Sample Output:
YES
NO
Explanation:
In the first test case we can convert “abcdefgh” into “cde” by deleting a,b,f,g and h. In the second test case we cannot convert “hello” to “hey”
EXPLANATION:
We just find whether the string B is present in String A or not. If it is present print YES else NO.
SOLUTION:
#include <iostream>
#include<ctime>
#include<map>
#define ll long long int
using namespace std;
void solve();
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("error.txt", "w", stderr);
// freopen("output.txt", "w", stdout);
// #endif
int t;
/*is Single Test case?*/ cin >> t;
while (t--) {
solve();
// cout << "\n";
}
// cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
return 0;
}
void solve()
{
string sa;
string sb;
cin>>sa;
cin>>sb;
if(sa.size()<sb.size())
cout<<"NO"<<endl;
else{
if(sa.find(sb)!=string::npos)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
}