Longest Common Subsequence
00:00
AmazonGoogleAdobe
Find the length of the longest common subsequence (LCS) of two strings. A subsequence maintains relative order but need not be contiguous.
Examples
Input → s1='abcde', s2='ace'
Output → 3
Note: LCS='ace'
Input → s1='abc', s2='abc'
Output → 3
Note: entire string
Input → s1='abc', s2='def'
Output → 0
Note: no common chars