SOURCE

var lengthOfLongestSubstring = function(s) {
let len = s.length
let result = 0
for(let i= 0; i < len; i++) {
    let set = new Set()
    let maxlen = 0
    let j = i
   
    while (j < len && !set.has(s[j])) {
        set.add(s[j])
        maxlen++
        j++
    }
     console.log([...set])
    result = Math.max(result,maxlen)
}
return result
};
console.log(lengthOfLongestSubstring('abcabcbb'))
console 命令行工具 X clear

                    
>
console