O71

Generate Balanced Parentheses

Junior Level Candidate
Target Time: 15 - 20 Minutes
Type: ARRAY

Problem Statement & Objective

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

Function Signature (Python)

generate_balanced_parentheses(n: int) -> list[str]

Input & Output Contract

Output Rule:Geçerli parantez dizgileri listesi.

System Constraints

1 <= n <= 8

Example Execution Walkthrough

n = 3 -> ['((()))', '(()())', '(())()', '()(())', '()()()']

Example Test Scenarios (3)

Example 1
Input:[3]
Expected Output:["((()))","(()())","(())()","()(())","()()()"]
Example 2: n=1
Input:[1]
Expected Output:["()"]
Example 3: n=2
Input:[2]
Expected Output:["(())","()()"]
Loading Python Editor...
Input Parameters
[
  3
]
Expected Output
[
  "((()))",
  "(()())",
  "(())()",
  "()(())",
  "()()()"
]