Skip to content

Longest common subsequence

planning ahead

Level 2 of 3

Also called LCS and Longest common subsequence, by dynamic programming.

Finds the most letters two words share in the same order, not necessarily side by side, such as eat in seat and eats. A table holds the answer for every start of the first word against every start of the second, each cell built from the cells before it.

letters in common: the first word down the side, the second along the top

cells filled
0

step 1 of 1

Examples

Two words of 1 to 7 letters each, a to z only, separated by a comma or a space, for example seat, eats.