@@ -0,0 +1,1413 @@
+import java.util.HashMap;%0A//3. Longest Substring Without Repeating Characters%0A/**%0A * Given a string, find the length of the longest substring without repeating characters.%0A * %0A * Examples:%0A * Given %22abcabcbb%22, the answer is %22abc%22, which the length is 3.%0A * Given %22bbbbb%22, the answer is %22b%22, with the length of 1.%0A * Given %22pwwkew%22, the answer is %22wke%22, with the length of 3. Note that the answer must be a substring, %22pwke%22 is a subsequence and not a substring.%0A * %0A * Tags: Hash Table, Two Pointers, String%0A * Similar Problems: (H) Longest Substring with At Most Two Distinct Characters%0A * %0A * @author Xinyue Zhang%0A *%0A */%0A%0Apublic class Solution %7B%0A    public int lengthOfLongestSubstring(String s) %7B%0A        if (s.length() == 0) return 0;%0A        //create a Hashmap, where character is key and index of the character is value%0A        HashMap%3CCharacter, Integer%3E map = new HashMap%3CCharacter, Integer%3E();%0A        int max = 0;%0A        //two pointers%0A        for (int i = 0, j = 0; i %3C s.length(); i++) %7B%0A            if (map.containsKey(s.charAt(i)))   %0A                j = Math.max(j, map.get(s.charAt(i)) + 1);%0A            map.put(s.charAt(i), i);%0A            max = Math.max(max, i - j + 1);%0A        %7D%0A        return max;%0A    %7D%0A    %0A    public static void main(String args%5B%5D) %7B%0A        String s = %22abba%22;%0A        Solution sol = new Solution();%0A        System.out.println(sol.lengthOfLongestSubstring(s));  %0A    %7D%0A%7D%0A

Add solution for problem 003