LC 22
Generate Parentheses
Medium · LC 1–100
Candidate solution routes
Balanced-Delimiter Stack
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.562 · metadata_only
Constraint-satisfaction backtracking
Invariant: At recursion entry, the partial assignment satisfies every activated constraint and every auxiliary set/count exactly matches it; a pruned branch has no legal completion.
candidate confidence: 0.610 · metadata_only
Subset / combination backtracking
Invariant: On entering dfs(start), path indices are strictly increasing and already fixed below start. The call generates exactly completions whose next index is at least start, preventing duplicate orders.
candidate confidence: 0.470 · metadata_only
Linear dynamic programming
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.470 · 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.