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 = 3Output: 5 strings
Example 2
n = 2Output: 2 strings
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.