public int len(String s) {
        if (s.length() == 0)
            return 0;
        HashMap<Character, Integer> window = new HashMap<Character, Integer>();
        int left = 0, max = 0;
        for (int i = 0; i < s.length(); ++i) {
            char c = s.charAt(i);
            if (window.containsKey(c)  && window.get(c) > left) {
                left = window.get(c) + 1;
            }
            window.put(c, i);
            max = Math.max(max, i - left + 1);
        }
        return max;
    }