var lengt = function(s) {
let max = 0;
let arr = [];
for(let i=0,l=s.length;i<l;i++){
let char=s[i];
let index = arr.indexOf(char);
if(index!==-1){
arr.splice(0,index + 1);
}
arr.push(char);
if(arr.length > max){
max = arr.length;
}
}
console.log(‘max‘,s,max);
return max;
}
lengt("rererere");
原文地址:https://www.cnblogs.com/ylq818/p/10596350.html
时间: 2024-11-02 16:06:29