int firstNonRepeating(char *str) { int *count = getCharCountArray(str); int index = -1, i; for (i = 0; *(str+i); i++) { if (count[*(str+i)] == 1) { index = i; break; } } free(count); return index; }
void firstNonRepeating(char *str) { changetolower(str); int *count = getCharCountArray(str); int i; for (i=0; i<NO_OF_CHARS; i++) printf("%d - %d\n",i, count[i]); for (i = 97; i <= 122; i++) { if (count[i] == 0) { printf("not panagram"); return; } } printf("panagram"); return; }
/* removeDirtyChars takes two string as arguments: First string (str) is the one from where function removes dirty characters. Second string is the string which contain all dirty characters which need to be removed from first string */ char *removeDirtyChars(char *str, char *mask_str) { int *count = getCharCountArray(mask_str); int ip_ind = 0, res_ind = 0; while (*(str + ip_ind)) { char temp = *(str + ip_ind); if (count[temp] == 0) { *(str + res_ind) = *(str + ip_ind); res_ind++; } ip_ind++; } /* After above step string is ngring. Removing extra "iittg" after string*/ *(str+res_ind) = '\0'; return str; }