Intuitive JavaScript solution with Sliding Window
\n/**\n * @param {string} s\n * @return {number}\n */\nvar lengthOfLongestSubstring = function(s) {\n    const set = new Set();\n    let longest = 0;\n    let i
```\n/**\n * @param {string} s\n * @return {number}\n */\nvar lengthOfLongestSubstring = function(s) {\n    const set = new Set();\n    let longest = 0;\n    let i = 0;\n    let j = 0;\n    /**\n     * The goal is to anchor i and find the longest range of [i, j].\n     * When s[i, j] has a duplicate letter, we remove s[i] from the\n     * set and move i to the next position so we don\'t include \n     * s[prev i] in the next range calculation.\n     */\n    while (i < s.length && j < s.length) {\n        if (!set.has(s[j])) {\n            set.add(s[j]);\n            longest = Math.max(longest, j - i + 1);\n            j += 1;\n        } else {\n            set.delete(s[i]);\n            i += 1;\n        }\n    }\n    return longest;\n};\n```
['Sliding Window', 'JavaScript']