public int lengthof(String s) {
        if (s.length() == 0)
            return 0;
        int[] hash_table = new int[256];
        Arrays.fill(hash_table, -1);
        int max = 0, ptr = 0;
        for (int i = 0; i < s.length(); ++i) {
            char c = s.charAt(i);
            if (hash_table[(int) c] != -1 && hash_table[c] >= ptr)
                ptr = hash_table[c] + 1;
            hash_table[(int) c] = i;
            max = Math.max(i - ptr + 1, max);
        }
        return max;
    }