Files
leetcode/src/387.c
2025-07-18 22:23:57 +08:00

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;
}