Java concise HashMap solution.
\n    public int lengthOfLongestSubstring(String s) {\n        int ret = 0;\n        Map<Character, Integer> map = new HashMap<>();\n        for (int i = 0, sta
    \n    public int lengthOfLongestSubstring(String s) {\n        int ret = 0;\n        Map<Character, Integer> map = new HashMap<>();\n        for (int i = 0, start = 0; i < s.length(); i++) {\n            char c = s.charAt(i);\n            if (map.containsKey(c)) \n                start = Math.max(map.get(c)+1, start);\n            ret = Math.max(ret, i-start+1); \n            map.put(c, i);\n        }\n        return ret;\n    }
['Java']