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.
1 parent 40a843f commit 36e6f97Copy full SHA for 36e6f97
2018.12.1-leetcode387/FFFro.md
@@ -0,0 +1,37 @@
1
+public class Solution {
2
+ public int FirstNotRepeatingChar(String str) {
3
+ if (str.length() == 0)
4
+ return -1;
5
+ int index = 1;
6
+ int[] temp = new int[26];
7
+ for (int i = 0; i < str.length(); i++) {
8
+ int a = (int)str.charAt(i) - 97;
9
+ if (temp[a] == 0){
10
+ temp[a] = index++;
11
+ }else {
12
+ temp[a] = -1;
13
+ }
14
15
+ char c = '#';
16
+ int res= Integer.MAX_VALUE;
17
+ for (int j = 0; j < temp.length; j++) {
18
+ if (temp[j] > 0){
19
+ if (temp[j] < res){
20
+ res = temp[j];
21
+ c = (char) (j+97);
22
23
24
25
+ if (c == '#'){
26
27
28
+ for (int k = 0; k < str.length(); k++) {
29
+ if (str.charAt(k) == c){
30
+ return k;
31
32
33
34
35
+
36
37
+}
0 commit comments