字符串出现的不重复最长长度
var lengthOfLongestSubstring=function(s){
const arr=[...s]
let res=1;
let result=arr.reduce((total,cur,i,arr)=>{
if(i==0){
return cur;
}else{
if(total.indexOf(cur)<0){
return total+cur
}else if(res<total.length){
res=total.length
return total.slice(total.indexOf(cur)+1,total.length)+cur
}else{
return total.slice(total.indexOf(cur)+1,total.length)+cur
}
}
},"")
if(res<result.length){
res=result.length
}
}