# 3-无重复字符的最长子串-中等
# 我的解答
# 官方解答
# 优质解答
[字节&Leetcode3:无重复字符的最长子串 · Issue #21 · sisterAn/JavaScript-Algorithms (github.com) (opens new window)](https://github.com/sisterAn/JavaScript-Algorithms/issues/21)
https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/solution/zi-jie-leetcode3wu-zhong-fu-zi-fu-de-zui-chang-zi-/
var lengthOfLongestSubstring = function(s) { let map = new Map(), 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(max, j - i + 1); map.set(s[j], j); } return max; };