Arrange Parentheses
STRING
RECURSION
BACKTRACKING

Problem

Given an integer n, generate all combinations of n pairs of balanced parentheses. Each pair consists of an opening parenthesis '(' and a closing parenthesis ')', such that each opening parenthesis is matched with a corresponding closing parenthesis in the correct order.

Examples:

generateBalancedParentheses(3) /* [ "((()))", "(()())", "(())()", "()(())", "()()()" ] */ generateBalancedParentheses(1) // ["()"]
Loading...