Given two strings S1 and S2, S = S1 - S2 is defined to be the remaining string after taking all the characters in S2 from S1. How to calculate S1 - S2 for any given strings as fast as possible?
for example :
Input:
They are students.
aeiou
Output:
Thy r stdnts.
I've tried the hash map,sadlly the judger said that it is too slow,but can any solution be faster ?
Here is my code :
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
bool occur[300]={false};
int main()
{
char str1[10002];
gets(str1);
char ch;
while((ch=getchar())!='\n')
occur[ch]=true;
int i;
for(i=0;i<strlen(str1);i++)
if(occur[str1[i]])
continue;
else
putchar(str1[i]);
putchar('\n');
return 0;
}