Skip to content

Commit 62e0fd3

Browse files
Create 神秘的火柴人.md
1 parent 7a5ebc8 commit 62e0fd3

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
...
2+
class Solution {
3+
public:
4+
int firstUniqChar(string s) {
5+
if(s.length() == 1)
6+
return 0;
7+
if(s.length() == 0)
8+
return -1;
9+
10+
map<char, int> m;
11+
int i = 0;
12+
for(i=0; i<s.length(); i++)
13+
{
14+
m[s[i]]++;
15+
}
16+
17+
for(i=0; i<s.length(); i++)
18+
{
19+
if(m[s[i]] == 1)
20+
break;
21+
}
22+
23+
if(i == s.length())
24+
return -1;
25+
else
26+
return i;
27+
}
28+
};
29+
...

0 commit comments

Comments
 (0)