Open ForeveHG opened 3 years ago
function findStr(str) { str = str.split(''); let current = [] let result = [] while(str.length > 0) { if(current.indexOf(str[0]) == -1) { current.push(str[0]) str = str.slice(1) } else { result.push(current.join('')); current = [] } } return result.sort((a,b) => b.length - a.length)[0]; } //测试 findStr('pwwkew') //wke