Given two strings s1 and s2, return the length of their longest common subsequence. If there is no common subsequence, return 0.
A subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters.
For example, "ace" is a subsequence of "abcde".
A common subsequence of two strings is a subsequence that is common to both strings.
Example :
Input : s1 = "ABCDGH", s2 = "AEDFHR"
Output: 3
Explanation : "ADH" is the LCS between s1 and s2
Input : s1 = "AGGTAB", s2 = "GXTXAYB"
Output: 4
Explanation : “GTAB” is the LCS between s1 and s2
Input : s1 = "ABCHG", s2 = "ABGCF"
Output: 3
Explanation : "ABC" & "ABG" is the LCS between s1 and s2
Given two strings s1 and s2, return the length of their longest common subsequence. If there is no common subsequence, return 0.
A subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters.
For example, "ace" is a subsequence of "abcde". A common subsequence of two strings is a subsequence that is common to both strings.
Example :