Dynamic ProgrammingEvidence Contributing

String Alignment / Subsequence DP

2D DP over two string indices to compare, align, or count subsequences/substrings between them.

Practice Problems: 7
Difficulty: 0 Easy·4 Medium·3 Hard

Algorithmic Intuition & Recognition

The String Alignment / Subsequence DP technique is applied when tackling problems characterized by specific invariants in the problem state or constraints:

  • Core Strategy: 2D DP over two string indices to compare, align, or count subsequences/substrings between them.
  • When to use: Look for opportunities where repeated re-computation can be replaced by maintaining monotonic properties, state windows, or relational pointers.
  • Interview Signal: Demonstrating this pattern shows mastery of Dynamic Programming foundations, reducing worst-case algorithmic complexity.

Canonical Practice Problems

7 problems

Curated Sheets Containing This Pattern

Related Algorithmic Patterns