We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents c3dfd2d + 89b3ddf commit 7428577Copy full SHA for 7428577
2018.12.1-leetcode387/我的微信名是空格.md
@@ -0,0 +1,18 @@
1
+ public static int firstUniqChar(String s) {
2
+ if(null == s || 0 == s.length()){
3
+ return -1;
4
+ }
5
+ int[] hash = new int[26];
6
+ char[] array = s.toCharArray();//s转为字符数组
7
+ for(int i = 0; i < array.length; i++){
8
+ int num = array[i] - 'a'; //表示这个字母在26个字母中所在的位置
9
+ hash[num]++;
10
11
+ for(int i = 0; i < array.length; i++){//从字符串出发
12
+ int num = array[i] - 'a';
13
+ if(hash[num] == 1){
14
+ return i;
15
16
17
18
0 commit comments