public class Solution {
    public int lengthOfLongestSubstring(String s) {
        if(s.length() < 2 ) return s.length();

        int bucket[] = new int[256];
        for(int i = 0; i < 256; i++){
            bucket[i] = -1;
        }

        int head = 0, result = 0;
        for(int tail = 0; tail < s.length(); tail++) {
            if(bucket[s.charAt(tail)] > -1) {
                int target = bucket[s.charAt(tail)] + 1;
                while (head < target) {
                    bucket[s.charAt(head)] = -1;
                    head++;
                }
            }

            bucket[s.charAt(tail)] = tail;
            result = (tail - head + 1) > result ? tail - head + 1 : result;
        }

        return result;
    }
}

@@ -73,56 +73,8 @@
 ) %7B%0A
-        if(s.length() %3C 2 ) return s.length();%0A%0A
     
@@ -113,24 +113,25 @@
 %0A        for
+ 
 (int i = 0; 
@@ -138,30 +138,27 @@
 i %3C 
-256; i++)%7B%0A           
+bucket.length; i++)
  buc
@@ -169,26 +169,16 @@
 i%5D = -1;
-%0A        %7D
 %0A%0A      

optimize #3