New update is available. Click here to update.

Generate Parentheses

Posted: 19 Dec, 2020
Difficulty: Easy

PROBLEM STATEMENT

Try Problem

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 sets of parentheses that can be formed with a given number of pairs.

Input Format:
The only line of input contains an integer ‘N’ representing the given number of parentheses.
Output Format:
The output contains all possible valid parentheses printed in different lines.
Note:
The order in which different combinations of well-formed parentheses are printed doesn't matter.
Constraints:
1 <= N <= 10

Time Limit: 1sec