代码一样的 但是测试提交通不过 是哪里写错了么
来源:7-5 LeetCode:3. 无重复字符的最长子串

就现在action4359761
2020-11-13
var lengthOfLongestSubstring = function(s) {
let l = 0;
let res = 0;
const map = new Map();
for (let r = 0; r < s.length; r += 1){
if (map.has(s[r]) && map.get(s[r]) >=1) {
l = map.get(s[r]) + 1;
}
res = Math.max(res, r - l + 1);
map.set(s[r], r);
}
return res;
}
如下图
写回答
1回答
-
可以把出错的case,贴近去,debug一下
052020-11-13
相似问题