Share my Java solution using HashSet
The idea is use a hash set to track the longest substring without repeating characters so far, use a fast pointer j to see if character j is in the hash set or 
The idea is use a hash set to track the longest substring without repeating characters so far, use a fast pointer j to see if character j is in the hash set or not, if not, great, add it to the hash set, move j forward and update the max length, otherwise, delete from the head by using a slow pointer i until we can put character j to the hash set.\n\n    public int lengthOfLongestSubstring(String s) {\n        int i = 0, j = 0, max = 0;\n        Set<Character> set = new HashSet<>();\n        \n        while (j < s.length()) {\n            if (!set.contains(s.charAt(j))) {\n                set.add(s.charAt(j++));\n                max = Math.max(max, set.size());\n            } else {\n                set.remove(s.charAt(i++));\n            }\n        }\n        \n        return max;\n    }
['Java']