Medium · Dynamic Programming
Longest Common Subsequence
Given two strings text1 and text2, return the length of their longest common subsequence: the longest sequence of characters that appears in both strings in the same relative order, not necessarily contiguously (0 if they share no character).
Examples
Example 1
{
"a": "abcde",
"b": "ace"
}Output: LCS = 3
Example 2
{
"a": "abc",
"b": "abc"
}Output: LCS = 3
Rebuild it in the studio
Open every published interview problem, solution, scene, and memory room free, with no account.