/**
* @param {string} s
* @return {number}
*/
var lengthOfLongestSubstring = function(s) {
//遍历字符串每个字符
let sArr=s.split("");
// console.log(sArr);
let sLength=[];
let l=0;
let maxLength=0;
//选定一个字符
for(charId in sArr){
//最长字符串数组
let LsArr=[sArr[charId]];
let bl=0;
// console.log("charId"+charId);
//从该字符往后
for(let i=Number(charId)+1;i<=sArr.length;i++){
// console.log(i);
if(bl==1){
break;
}
if(i==sArr.length){
sLength.push(1);
break;
}
let Lsi=0;
while(1){
let LsL=LsArr.length;
//如果与前面字符相等,输出字符串长度,跳出循环
if(sArr[i]==LsArr[Lsi]){
l=LsArr.length;
sLength.push(l);
bl=1;
break;
}
//没有发现重复的
Lsi++;
//遍历完,跳出循环
if(Lsi==LsL){
LsArr.push(sArr[i]);
if(i==sArr.length-1){
}
break;
}
}
}
// console.log("sLength"+sLength);
}
console.log(sLength);
for(let i=0;i<sLength.length;i++){
if(maxLength<=sLength[i]){
maxLength=sLength[i];
}
}
return maxLength;
};
console.log(lengthOfLongestSubstring("au"));
console