Geeksforgeeks

X

DAYS

:

HOUR

:

MINS

:

SEC

Error

Copied to Clipboard

Given an integer **N** representing the number of pairs of parentheses, the task is to generate all combinations of well-formed(balanced) parentheses.

**Example 1:**

**Input**:
N = 3
**Output:**
((()))
(()())
(())()
()(())
()()()

**Input**:
N = 1
**Output:**
()

You don't need to read input or print anything. Complete the function

1 ≤ N ≤ 12

We are replacing the old Disqus forum with the new Discussions section given below.

Click here to view old Disqus comments.

Click here to view old Disqus comments.

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

YesLoading...

Generate Parentheses

...