Given two strings, find the length of the longest common subsequence (LCS) that appears in the same relative order in both strings, but not necessarily contiguously.
Explanation: The longest common subsequence is 'bcd' which has a length of 3 characters.
Explanation: The longest common subsequence is the string itself when both strings are identical, resulting in a length of 6.
Explanation: Since there are no characters in common in the same relative order between 'abcdefgh' and 'xyz', the longest common subsequence has a length of 0.
Longest shared subsequence of two strings
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak