17 lines
317 B
C
17 lines
317 B
C
#include <solution/387.h>
|
|
#include <string.h>
|
|
|
|
int firstUniqChar(char *s)
|
|
{
|
|
int hash[26];
|
|
memset(hash, 0, sizeof(int) * 26);
|
|
|
|
for (int idx = 0; s[idx]; idx++)
|
|
hash[s[idx] - 'a']++;
|
|
|
|
for (int idx = 0; s[idx]; idx++)
|
|
if (hash[s[idx] - 'a'] == 1)
|
|
return idx;
|
|
|
|
return -1;
|
|
} |