Skip to content
C

Generate Balanced Parentheses

Mediumjavapythonccppjavascript

Given N pairs of parentheses, generate every string of 2N characters in which every opening parenthesis is correctly matched.

Input Format

A single line containing the integer N.

Output Format

Print all valid strings, one per line, in lexicographic order (treating ( as smaller than )).

Input (stdin)

Output

Run your code to see output here...