Skip to content

Commit 1b12334

Browse files
authored
Merge pull request gzc426#273 from GatesMa/patch-3
Create GatesMa.md
2 parents 547d29b + 523ece3 commit 1b12334

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

2018.12.1-leetcode387/GatesMa.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# c++
2+
```cpp
3+
class Solution {
4+
public:
5+
int firstUniqChar(string s) {
6+
int chnum[26];
7+
memset(chnum, 0, sizeof(chnum));
8+
int len = s.length();
9+
for(int i=0;i<len;i++){
10+
chnum[s[i] - 'a']++;
11+
}
12+
for(int i=0;i < len;i++){
13+
if(chnum[s[i] - 'a'] == 1){
14+
return i;
15+
}
16+
}
17+
return -1;
18+
}
19+
};
20+
```

0 commit comments

Comments
 (0)