public int lengthOfLongestSubstring(String s) {
        if(s == null || s.length() == 0) return 0;
        
        Set<Character> chs = new HashSet<Character>();
        int start = 0, res = 1;
        
        for(int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if(chs.contains(ch)) {
                while(s.charAt(start) != ch && start != i) {
                	chs.remove(s.charAt(start));
                	start++;
                }
                start++;
            } else {
                chs.add(ch);
                if(i - start + 1 > res) res = i - start + 1;
            }
        }
        
        return res;
	}