AlgoFrames

Fill the LCS table

Warm-up · Trace the algorithm · about 5 min

Follow the longest-common-subsequence table for BAD and ABD. Answer each question before the step plays.

Example 1

Input:

{"text":"BAD","pattern":"ABD"}

Output:

2

Constraints

  • The trace uses the strings shown.

Learn the idea first: String DP: LCS, edit distance, palindromic subsequence, a visual lesson.

More String DP: LCS, edit distance, palindromic subsequence problems