Medium · Backtracking

Generate Parentheses

Given an integer n, return every string of n '(' and n ')' characters that is a well-formed (balanced) parentheses sequence, in any order.

Examples

Example 1

n = 3

Output: 5 strings

Example 2

n = 2

Output: 2 strings

Rebuild it in the studio

Open every published interview problem, solution, scene, and memory room free, with no account.

More Backtracking problems