class Solution {
    public int lengthOfLongestSubstring(String s) {
        int[] last = new int[128];
        Arrays.fill(last, -1);
        int start = 0;
        int ans = 0;
        for (int i = 0; i < s.length(); ++i) {
            if (last[s.charAt(i)] != -1) {
                start = Math.max(start, last[s.charAt(i)] + 1);
            }
            last[s.charAt(i)] = i;
            ans = Math.max(ans, i - start + 1);
        }
        return ans;
    }
}

@@ -1,8 +1,254 @@
+// Using a hashtable to remember the last index of every char. And keep tracking the starting point of a valid substring.%0A// start = max(start, last%5Bs%5Bi%5D%5D + 1)%0A// ans = max(ans, i - start + 1)%0A// Time complexity: O(n)%0A// Space complexity: O(128)%0A
 class So
@@ -506,17 +506,16 @@
  != -1) 
-%7B
 %0A       
@@ -575,22 +575,8 @@
 1);%0A
-            %7D%0A
     

add LongestSubstringWithoutRepeatingCharacters.java