Skip to content

Commit 5205880

Browse files
authored
Create 018429.c
1 parent a46a1d0 commit 5205880

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

018429.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
int firstUniqChar(char* s) {
2+
int ascii[256]={0};
3+
int i=0,len;
4+
while(s[i]!='\0')
5+
{
6+
i++;
7+
}
8+
len=i;
9+
for(i=0;i<len;i++)
10+
{
11+
ascii[s[i]]++;
12+
}
13+
i=0;
14+
while(ascii[s[i]]!=1&&i<len) i++;
15+
if(i==len)
16+
return -1;
17+
return i;
18+
}

0 commit comments

Comments
 (0)