public static int lengthOfLongestSubstring(String s) {//AC
    	if (s == null) return 0;
    	int table[] = new int[256];
    	int start = 0;
    	int max = 0;
    	Arrays.fill(table, -1);
    	for (int i = 0; i < s.length(); ++i) {
    		char curr = s.charAt(i);
    		if (table[curr] == -1) {
    			table[curr] = i;
    		}
    		else {//already in the table
    			start = Math.max(start, table[curr]+1);
    			table[curr] = i;
    		}
    		max = Math.max(max, i-start+1);
    	}
    	System.out.println(max);
    	return max;
    }