While most solution create a frequency map, thats not our goal. We are only interested if an element occurs more than once. So the only frequencies that matter are 0,1 and more than 1.

Hence I am limiting frequency to 2 and using a byte to store it, which is 4 times smaller than int. Can't use boolean since I need to store 3 types of values.

```
public class Solution {
public int firstUniqChar(String s) {
byte[] b = new byte[26];
int len = s.length();
for(int i=len-1;i>-1;i--){
int c = s.charAt(i) - 97;
b[c] = (byte)Math.min(b[c]+1,2); //limit frequency to 2
}
for(int i=0;i<len;i++){
int c = s.charAt(i) - 97;
if(b[c] == 1)
return i;
}
return -1;
}
}
```