/**
 * Given a string, find the length of the longest substring without repeating characters.
 * Given "abcabcbb", the answer is "abc", which the length is 3.
 * Complexity : O(n) time, O(n) space
 */
public class Solution {
    public int lengthOfLongestSubstring(String s) {
        int i = 0; // first pointer
        int j = 0; // second pointer
        int size = s.length();
        HashSet<Character> set = new HashSet<Character>();
        int result = 0;
        while ( i < size && j < size) {
            // adds only the unique values
            if (!set.contains(s.charAt(i))) {
                i++;
                set.add(s.charAt(i - 1));
                // j - i, since that will give use the length of the substring
                result = Math.max(result, i - j);

            } else {
                j++;
                set.remove(s.charAt(j - 1));


            }
        }
        return result;
    }
}

@@ -218,18 +218,16 @@
 ution %7B%0A
-  
   public
@@ -268,28 +268,24 @@
 ng s) %7B%0A
-    
     int 
 i = 0; /
@@ -276,17 +276,17 @@
     int 
-i
+j
  = 0; //
@@ -291,11 +291,11 @@
 // f
-irs
+ron
 t po
@@ -304,25 +304,21 @@
 ter%0A    
-    
 int 
-j
+i
  = 0; //
@@ -322,14 +322,12 @@
  // 
-second
+back
  poi
@@ -331,28 +331,24 @@
 pointer%0A    
-    
 int size = s
@@ -354,28 +354,24 @@
 s.length();%0A
-    
     HashSet%3C
@@ -413,20 +413,16 @@
 ter%3E();%0A
-    
     int 
@@ -433,20 +433,16 @@
 lt = 0;%0A
-    
     whil
@@ -465,30 +465,24 @@
 j %3C size) %7B%0A
-      
       // add
@@ -506,22 +506,16 @@
  values%0A
-      
       if
@@ -558,20 +558,66 @@
     
-        i++;
+// Move the back pointer, increasing the substring length.
 %0A   
@@ -613,32 +613,37 @@
 length.%0A        
+i++;%0A
         set.add(
@@ -660,24 +660,16 @@
  - 1));%0A
-        
         
@@ -675,13 +675,13 @@
  // 
-j - i
+i - j
 , si
@@ -731,24 +731,16 @@
 bstring%0A
-        
         
@@ -773,29 +773,22 @@
 i - j);%0A
-%0A   
       
-   
 %7D else %7B
@@ -800,20 +800,67 @@
     
-        j++;
+// Move the front pointer, decreasing the substring length.
 %0A   
@@ -860,24 +860,29 @@
 th.%0A        
+j++;%0A
         set.
@@ -910,38 +910,22 @@
 ));%0A
-%0A%0A   
       
-   %7D%0A    
+%7D%0A
     %7D%0A
-    
     
@@ -939,16 +939,14 @@
 result;%0A
-  
   %7D%0A%7D%0A

Fix comments and styling