LC 97

Interleaving String

Medium · LC 1–100

dynamic-programmingstring
Free

Candidate solution routes

Primary

Linear dynamic programming

Free

Invariant: After processing i, every state through i equals the true value under its definition, and every future transition reads only these finalized states.

candidate confidence: 0.400 · metadata_only

Alternate 1

Bitmask dynamic programming

Free

Invariant: dp[mask] is optimal among all legal sequences producing exactly mask, and transitions start from already-correct smaller states.

candidate confidence: 0.368 · metadata_only

Alternate 2

Subsequence dynamic programming

Free

Invariant: Every computed state exactly matches its endpoint/prefix definition and includes all legal final match, skip, or edit actions.

candidate confidence: 0.350 · metadata_only

Alternate 3

Grid dynamic programming

Free

Invariant: When cell (r,c) is processed, every predecessor state already meets its definition; the new state aggregates every legal way to enter the cell exactly as required.

candidate confidence: 0.350 · metadata_only

How to use this page

Read the statement and constraints first, then validate recognition signals, invariant, and complexity. Candidate score is not correctness evidence.