FreeCareerPath
Build the PrimitiveMedium

Longest Common Subsequence

Write `longest_common_subsequence(a, b)` returning the length of the longest subsequence present in both strings. Subsequences need not be contiguous. longest_common_subsequence("abcde", "ace") -> 3 Two transitions and that is the whole problem: if the characters match, take the diagonal plus one; if not, take the better of dropping one character from either string. This table is the template for Edit Distance and the diff algorithms.

What to expect: A timer starts when you begin. Edit the starter code, run it against the test suite as many times as you like, then finish when you're done. The reference solution and interviewer follow-up questions unlock only after you finish.

Log in to start this session

Timed sessions and your results for "Longest Common Subsequence" are saved to your account — logging in takes a few seconds.

Longest Common Subsequence — FreeCareerPath