Generate Parentheses

Medium · Backtracking · about 15 minutes

Asked at Google, Amazon, Meta, Uber.

Given n, return every string of n pairs of parentheses that is well-formed, in any order.

Related guides