This commit is contained in:
2025-07-18 22:23:57 +08:00
parent 2a7d5ed0cc
commit 6df3e30818
3 changed files with 79 additions and 0 deletions

17
src/387.c Normal file
View File

@@ -0,0 +1,17 @@
#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;
}