{
if(text1.length===0 || text2.length===0){
return 0;
}
if (text1.charAt(0)===text2.charAt(0)){
return longestCommonSubsequence(text1.slice(1),text2.slice(1))+1;
}
else{
return Math.max(
longestCommonSubsequence(text1,text2.slice(1)),
longestCommonSubsequence(text1.slice(1),text2)
);
}
};
Yes
because recursion is bad in JS, or do u have other feedback
Why .charAt(0) when [0] exists? Why .slice(1) when you can just pass starting indexes?
Обсуждают сегодня