public int lengthOfLongestSubstring(String s) {
        int[] table = new int[256];
        Arrays.fill(table, -1);
        int len = 0;
        int max = 0;
        for(int i = 0; i < s.length(); i++){
            if(table[s.charAt(i)] != -1){
                max = Math.max(max, len);
                len = 0;
                i = table[s.charAt(i)] + 1;
                Arrays.fill(table, -1);
            }
            table[s.charAt(i)] = i;
            len++;
        }
        return Math.max(max, len);
    }