public class Solution {

public int firstUniqChar(String s) {

```
int[] arr = new int[26];
if(s == null || s.length() == 0) {
return -1;
}
int n = s.length();
int j = 0;
for(int i = 0;i < n;i++) {
while(j < n) {
if(arr[s.charAt(j) - 'a']++ == 0 || arr[s.charAt(i) - 'a'] < 2) {
j++;
} else {
break;
}
}
if(j == n) {
return i;
}
}
return -1;
}
```

}