Dodomeki
Sign in

89. Common Subsequence

Medium

Given the strings textoA and textoB, return the length of the longest subsequence common to both. The chosen characters must keep their original order in each string, but do not need to be adjacent.

Example 1
Input: textoA = "caderno", textoB = "cadeado"
Output: 5
Explanation: "cadeo" appears as a subsequence in both strings.
Example 2
Input: textoA = "abc", textoB = "ac"
Output: 2
Constraints
  • 0 <= textoA.length, textoB.length <= 1000
Dynamic programmingStrings
Caso 1
textoA =
"caderno"
textoB =
"cadeado"
Expected =
5
Caso 2
textoA =
"abc"
textoB =
"ac"
Expected =
2

Run checks these 2 cases. Submit runs all 6, including hidden ones.