int deleteChars(char *first, char *second){
if(!first||!second) return -1;
bool hashTable[256];
memset(hashTable,0,sizeof(hashTable)*sizeof(bool));
for (int i=0;i<strlen(second);++i)
{
hashTable[(unsigned char)second[i]] = true;
}
char *fast=first;
char *slow=first;
while(*fast){
if(!hashTable[*fast]){
*slow = *fast;
++slow;
}
++fast;
}
*slow = 0;
return 0;
}
hash的思想,只是处理ascii字符,时间复杂度O(N+M),空间复杂度O(1)。