Skip to content

Commit f852924

Browse files
authored
Merge pull request gzc426#171 from V1ncentzzZ/master
2018.11.30 打卡
2 parents f26ebcf + 1df29f2 commit f852924

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)