Skip to content

Commit 373999b

Browse files
authored
Merge pull request gzc426#173 from MMzhe/patch-6
Create sourcema.md
2 parents a6209e4 + dc3fc03 commit 373999b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

2018.12.1-leetcode387/sourcema.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# LeetCode 387
2+
class Solution {
3+
public int firstUniqChar(String s) {
4+
if (s.length() == 0 || s == null) {
5+
return -1;
6+
}
7+
int[] arr = new int[26];
8+
for (int i = 0; i < s.length(); i++) {
9+
arr[s.charAt(i) - 'a']++;
10+
}
11+
for (int i = 0; i < s.length(); i++) {
12+
if (arr[s.charAt(i)-'a']==1) {
13+
return i;
14+
}
15+
}
16+
return -1;
17+
}
18+
}

0 commit comments

Comments
 (0)