Problem title
Difficulty
Avg time to solve

Predict the Winner
Moderate
25 mins
Longest Balanced Substring
Moderate
25 mins
Pairwise Sum of Hamming Distance
Moderate
30 mins
URL Shortener
Easy
10 mins
Different Bits Sum Pairwise
Easy
15 mins
Cut The Paper
Hard
10 mins
Meta Strings
Easy
10 mins
Accounts Merge
Hard
15 mins
Check for Duplicate Subtree
Hard
15 mins
Check Difference
Easy
15 mins
1

Generate all parenthesis

Difficulty: HARD
Avg. time to solve
45 min
Success Rate
55%

Problem Statement

Given n pairs of parentheses, write a function to generate and print all combinations of well-formed parentheses. That is, you need to generate all possible valid set of parenthesis that can be formed with given number of pairs.

Input format :
Integer n
Output format :
Print all possible valid parenthesis in different lines

Note: Order in which different combinations of well-formed parentheses are printed in different lines doesn't matter.

Constraints :

1 <= n <= 10

Sample Input :
3
Sample Output :
((()))
(()())
(())()
()(())
()()()
Reset Code
Full screen
copy-code
Console