Extraction of secret message

PROBLEM :

Mridushi likes to play with strings. One day Vaibhav challenged her and gave her some strings. Each string contains some secret message. Vaibhav mixed the secret message with some specified substring "LIE" .

For eg. "I AM COOL" is given as "LIELIEILIEAMLIECOOL".

But Mridushi has to leave for some urgent work. So in the absence of her, help to find out the secret message.


Input:

First line contains the number of test cases, T.
First line of each test case contains the string, M.

Output:

Print the secret message.


Constraints:

1<=T<=10
Length of string doesnt exceed 200 characters.


Example:

Input

2
LIELIEILIEAMLIECOOL
LIELIEABCLIELIELIE


Output
I AM COOL
ABC

--------------------------------------------------------------------------------
SIMPLE c++ IMPLEMENTATION :
--------------------------------------------------------------------------------

#include<iostream>
using namespace std;
#include<string.h>
int main()
 {
int t,l,i ;
char str[200] ;
cin>>t ;
while(t--)
{
   scanf(" %[^\n]s",str) ;
 
   l=strlen(str) ;
 
   for(i=0;i<l;i++)
   {
       if(str[i]=='L'&&str[i+1]=='I'&&str[i+2]=='E')
       i+=2 ;
       else
       {
           cout<<str[i] ;
           if(str[i+1]=='L'&&str[i+2]=='I'&&str[i+3]=='E')
               cout<<" " ;
       }
   }
   cout<<endl ;
}
return 0;
}

---------------------------------------------------------------------------------

Comments

Popular posts from this blog

Count ways to N'th Stair(Order does not matter)

Replace all ‘0’ with ‘5’ in an input Integer

Chocolate Distribution Problem

Remove characters from the first string which are present in the second string

Primality Test ( CodeChef Problem code: PRB01 )