✅Generate all parentheses(Contest)
Generate all parentheses easy Time Limit: 2 sec Memory Limit: 128000 kB
Problem Statement :
Given an integer N, print all balanced bracket strings of length 2*N. A bracket string is a string that contains only '(' and ')' as its characters.
Empty string is a balanced bracket string
If S is a balanced bracket string, so is (S)
If S and T are balanced bracket strings, so is ST Print in lexicographical order. '(' appears before ')' in lexicographical orderInputThe single line of input containing an integer N. 1 <= N <= 15OutputPrint all possible balanced bracket strings of length 2*N in a separate line.ExampleSample Input 1: 1 Sample Output 1: () Sample Input 2: 3 Sample Output 2: ((())) (()()) ()(()) ()()() Explanation: It is printed in lexicographical order .
link:https://my.newtonschool.co/playground/code/sapyq16sbt10/
Last updated