Preview:
var lengthOfLongestSubstring = function(s) {
    let start = -1;
    let maxLength = 0;
    let Obj = {};
    
    for(let i = 0; i < s.length; ++i){
        if(Obj[s[i]] >= 0 && Obj[s[i]] > start){
            start = Obj[s[i]];
        }
        maxLength = Math.max(maxLength, i - start);
        Obj[s[i]] = i;
    }
    return maxLength;
};
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter