02.07 · Problem
Generate Parentheses
Return every valid string of n pairs of brackets: every ( is closed by a later ). Any order is fine.
Examples
Example 1
Input: n = 3
Output: ["((()))", "(()())", "(())()", "()(())", "()()()"]
Example 2
Input: n = 1
Output: ["()"]solulu Pro
Continue this problem with Pro
Inside: step-by-step hints · 7 hidden tests · reference solutions · code editor.
Lifetime ₹1,999 ₹999 · Launch offer
Item 18 of 44 · updated 2026-10-13