SOURCE

var lengthOfLongestSubstring = function(s) {
   let map =new Map();
   let max =0;
   for(let i=0,j=0;j<s.length;j++){  
       if(map.has(s[j])){
           i = Math.max(map.get(s[j])+1,i); 
       }
       max = Math.max(j-i+1,max);
       map.set(s[j],j);
      console.log(s[j],JSON.stringify([...map.entries()]))
   }
   console.log(max)
}
lengthOfLongestSubstring('abcabcbb');




        
            
console 命令行工具 X clear

                    
>
console