TheAlgorithms-C/leetcode/src/387.c
2020-06-28 15:25:37 +00:00

13 lines
259 B
C

int firstUniqChar(char *s)
{
int *arr = calloc(256, sizeof(int));
int i;
for (i = 0; i < strlen(s); i++) arr[s[i]] = arr[s[i]] + 1;
for (i = 0; i < strlen(s); i++)
{
if (arr[s[i]] == 1)
return i;
}
return -1;
}