Skip to content

Commit 76e0c19

Browse files
authored
Create 。。。.md
1 parent ac4d8ed commit 76e0c19

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

2018.12.1-leetcode387/。。。.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Solution {
2+
public int firstUniqChar(String s) {
3+
if (s.trim().length() == 0)return -1;
4+
int result = Integer.MAX_VALUE;
5+
Map<Character,Integer> map = new HashMap<>();
6+
for (int i = 0; i < s.length(); i++){
7+
if (map.containsKey(s.charAt(i))){
8+
map.put(s.charAt(i),Integer.MAX_VALUE);
9+
}else {
10+
map.put(s.charAt(i),i);
11+
}
12+
}
13+
for (int i : map.values()){
14+
result = Math.min(i,result);
15+
}
16+
if (result == Integer.MAX_VALUE)result=-1;
17+
return result;
18+
}
19+
}

0 commit comments

Comments
 (0)