public class Solution { public int lengthOfLongestSubstring(String s) { int size=s.length(); int[] map=new int[206]; int maxLen=0; for(int i=0;i<size;i++) { refresh(map); int start=i; int end=start+1; map[s.charAt(start)]=1; while(end<size) { if(map[s.charAt(end)]==0) map[s.charAt(end)]=1; else break; end++; } int len=end-start; if(len>maxLen) { maxLen=len; } } return maxLen; } public void refresh(int [] map) { int size=map.length; for(int i=0;i<size;i++) map[i]=0; } }