Skip to main content
mediumNeetCode 150

Generate Parentheses

Given n pairs of parentheses Generate all combinations of well-formed parentheses Example: n = 3 => ["((()))","(()())","(())()","()(())","()()()"]

Generate Parentheses is a dynamic programming question: define the state cleanly and the transitions usually follow. Interviewers love it because it reveals your state-and-transition thinking and your edge-case discipline. The trap is picking a state that's too vague; keep it minimal and consistent.

StringBacktrackingDynamic Programming

Meet Coco

Coco is an AI study partner, not a person. She listens while you explain your code, asks what a line does and never hands you the fix. Typing with Coco is free when you sign in, up to a daily limit. Talking with her out loud comes with the $79 pack. Anyone can open the editor and run their code.

1Generate Valid Parentheses Combinationsmedium
Based onLeetCode