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 f26ebcf + 1df29f2 commit f852924Copy full SHA for f852924
2018.12.1-leetcode387/。V1ncentzzZ.md
@@ -0,0 +1,35 @@
1
+LeetCode387:https://leetcode-cn.com/problems/first-unique-character-in-a-string/
2
+
3
+给定一个字符串,找到它的第一个不重复的字符,并返回它的索引。如果不存在,则返回 -1。
4
5
+案例:
6
7
+s = "leetcode"
8
+返回 0.
9
10
+s = "loveleetcode",
11
+返回 2.
12
13
14
+注意事项:您可以假定该字符串只包含小写字母。
15
16
+class Solution {
17
18
+ // TODO 未用indexOf版本
19
+ // public int firstUniqChar(String s) {
20
+ // s = s.trim();
21
+ // if("".equals(s)) return -1;
22
+ // if(s.length() == 1) return 0;
23
+ // char[] chars = s.toCharArray();
24
+ // outer:for(int i=0; i<chars.length; i++){
25
+ // for(int j=0; j<chars.length; j++){
26
+ // if(j == i) continue;
27
+ // if(chars[j] ==chars[i]){
28
+ // continue outer;
29
+ // }
30
31
+ // return i;
32
33
+ // return -1;
34
35
+}
0 commit comments