JavaScript Clean Heavily Commented Solution
Time Complexity = O(N)\nSpace Complexity = O(N)\njavascript\nvar lengthOfLongestSubstring = function(s) {\n    // keeps track of the most recent index of each l
Time Complexity = `O(N)`\nSpace Complexity = `O(N)`\n```javascript\nvar lengthOfLongestSubstring = function(s) {\n    // keeps track of the most recent index of each letter.\n    const seen = new Map();\n    // keeps track of the starting index of the current substring.\n    let start = 0;\n    // keeps track of the maximum substring length.\n    let maxLen = 0;\n    \n    for(let i = 0; i < s.length; i++) {\n        // if the current char was seen, move the start to (1 + the last index of this char)\n        // max prevents moving backward, \'start\' can only move forward\n        if(seen.has(s[i])) start = Math.max(seen.get(s[i]) + 1, start)\n        seen.set(s[i], i);\n        // maximum of the current substring length and maxLen\n        maxLen = Math.max(i - start + 1, maxLen);\n    } \n    \n    return maxLen;  \n};\n```
['JavaScript']