/**
* @param {string} s
* @return {number}
*/
var lengthOfLongestSubstring = function(s) {
let arr = s.split('')
let result = []
let max = 0
for(let i=0;i<arr.length;i++){
if(!result.includes(arr[i])){
result.push(arr[i])
max = Math.max(max,result.length)
}else{
result.splice(0,result.indexOf(arr[i])+1)
result.push(arr[i])
}
}
return max
};
找到字符串的最长无重复字串
最新推荐文章于 2024-07-11 17:24:39 发布