0PricingLogin
Competitive Programming Academy · Lesson

Longest Common Subsequence

Align two strings with a DP table.

What a Subsequence Is

A subsequence keeps characters in order but may skip some. From 'abcde' you can take 'ace', but never 'aec'.

The LCS Goal

Given two strings, the longest common subsequence is the longest sequence that appears in both, in the same relative order.

All lessons in this course

  1. Path Counting on a Grid
  2. Minimum Path Sum with Obstacles
  3. Longest Common Subsequence
  4. Edit Distance Step by Step
← Back to Competitive Programming Academy