var longestCommonSubsequence = function(t1, t2) {
let len1=t1.length
let len2=t2.length
let dp=Array(len1+1).fill(0).map(()=>Array(len2+1).fill(0))
for(let i=1;i<=len1;i++){
for(let j=1;j<=len2;j++){
if(t1[i-1]==t2[j-1]){
dp[i][j]=dp[i-1][j-1]+1
}else{
dp[i][j]=Math.max(dp[i-1][j],dp[i][j-1])
}
}
}
return dp[len1][len2]
};