LC 32

Longest Valid Parentheses

Hard · LC 1–100

dynamic-programmingstackstring
Free

Candidate solution routes

Primary

Balanced-Delimiter Stack

Free

Invariant: After a prefix, the stack contains exactly its unmatched openers in occurrence order; the top is the only opener the next closer may legally match.

candidate confidence: 0.740 · 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.