
Balanced Parentheses (hard)
Problem Statement
For a given number N, write a function to generate all combination of N pairs of balanced parentheses.
Example 1:
Input: N=2
Output: (()), ()()
Example 2:
Input: N=3
Output: ((())), (()()), (())(), ()(()), ()()()
Constraints:
0 <= n <= 8
With n = 0 there is nothing to balance, so the only valid string is the empty one and the answer is [""].
Try it yourself
Try solving this question here:
Python3
Python3
. . . .
.....
.....
.....
Unlock this and all other premium problems.
No code editor for this lesson
This lesson focuses on concepts and theory