Dsa
Backtracking
Medium
Unique Parentheses Combinations
Given an integer n, write a program to generate all combinations of well-formed parentheses of length 2n. Each combination should be unique.
Input:
A single integer n (1 <= n <= 8).
Output:
Print each unique combination on a new line.
Example:
Input:
3
Output:
((()))
(()())
(())()
()(())
()()()
Key concepts
backtrackingcombinatoricsgeneration
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now