# Playful String

QUESTION

KillCode is trying to learn strings but failing to solve the recursive approach given by his Teacher. His Teacher gave him a string consisting of lower case alphabetes only , He asked to find a substring in the given string after removing any charaters from the original string . For example if the string is\n\n\” Cypher\”\nand the substring is \”yer\”, Killcode can remove p,h from the string and can form the given substring.\n\nNow the Teacher got impressed from Killcode and decided to increase the difficulty by asking to find the substring and reverse of substring in given string. If both substring can be formed by a given string by removing certain characters , print \”GOOD STRING \” else print \”BAD STRING\”.\nContraints\n\n1<=t<=10 1<=|s|<=100000\n\nInput -\nFirst line contains integer t denoting the test cases, each test case contains two lines containing two strings.\nOutput-\nPrint \”GOOD STRING\”(without quotes) both strings can be formed by given string else print \”BAD STRING\”.

``````#include <stdio.h>
#include <string.h>
#include <stdbool.h>

char str,sub;
bool isSubstring()
{
int i=0,j=0;
while(str[i]!='\0' && sub[j]!='\0'){
if(str[i]==sub[j]){
i++;
j++;
}
else
i++;
}
if(j==strlen(sub))
return true;
return false;
}
int main()
{
int t,i,j,k;
char ch;
scanf("%d",&t);
for(i=1;i<=t;i++){
scanf("%s",str);
scanf("%s",sub);

if(isSubstring()){
j=0;
k=strlen(sub)-1;
while(j<k){
char ch=sub[j];
sub[j]=sub[k];
sub[k]=ch;
j++;
k--;
}
if(isSubstring())
printf("GOOD STRING");
else 