Map<Character, Integer> temp = new HashMap();

```
int current=1;
int max=0;
for(int i=1;i<s.length()+1;i++){
if(temp.containsKey(s.charAt(i-1))){
current=Math.max(temp.get(s.charAt(i-1))+1,current);
}
max = Math.max(max,i-current+1);
temp.put(s.charAt(i-1),i);
}
return max;
```