We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Hi Alexhans,
check the wikipedia page for the Longest Common Subsequent problem: https://en.wikipedia.org/wiki/Longest_common_subsequence_problem
You have to find the length of the longest subsequence common to the both of the strings, and it's different from the problem of finding common substrings: unlike substrings, subsequences are not required to occupy consecutive positions.
Subsequence definition: "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements".
Consider X = XMJYAUZ and Y = MZJAWXU
The longest common subsequence between X and Y is MJAU
As you can see, in the subsequences there can be missing chars (compared to the original strings), but the important thing is that any char in the common subsequence is present in both the input strings (in the same order).
Magic Spells
You are viewing a single comment's thread. Return to all comments →
Hi Alexhans,
check the wikipedia page for the Longest Common Subsequent problem: https://en.wikipedia.org/wiki/Longest_common_subsequence_problem
You have to find the length of the longest subsequence common to the both of the strings, and it's different from the problem of finding common substrings: unlike substrings, subsequences are not required to occupy consecutive positions.
Subsequence definition: "In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements".
Consider X = XMJYAUZ and Y = MZJAWXU
The longest common subsequence between X and Y is MJAU
As you can see, in the subsequences there can be missing chars (compared to the original strings), but the important thing is that any char in the common subsequence is present in both the input strings (in the same order).