Dynamic programming · 8 / 15 Exercise Hard

Longest common subsequence

Objective

A subsequence is obtained by deleting characters without changing the order of the others (they need not be contiguous). With a table dp[i][j] you compute the length of the longest common subsequence of the prefixes of both strings.

Instructions

  • Read two lines of text (no spaces, not empty).
  • Show Length: n with the length of their longest common subsequence.
Input
abcde
ace
Output
Length: 3

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise