//输入两个字符串,查找最长字串
function findMaxStr(txt1,txt2){
let chidStr = new Set()
for(let i = 0 ;i<txt1.length ; i++){
for(let j = 0 ;j<txt1.length ; j++){
let rundomStr = ""
if(j<i){
rundomStr = txt1.substr(j,i+1)
}else {
rundomStr = txt1.substr(i,j+1)
}
if(rundomStr.length>0 && txt2.indexOf(rundomStr+"")>=0){
chidStr.add(rundomStr.toString())
}
}
}
let arrayStr = [...chidStr]
arrayStr.sort(function (a,b){
return b.length - a.length
})
console.log(chidStr)
console.log(arrayStr[0])
}
// findMaxStr('hello123word','hello123abc4')
// findMaxStr('hiword','hiweb')
// findMaxStr('private_void_method','public_void_method')
findMaxStr('h12hd',',12etd')